You may have seen the error message "JUser: :_load: Unable to load user" and wondered if it would be possible to easily update all articles that display an error after the author or editor of the article has been deleted from the system on purpose or by accident. The alternative, manual editing and updating each article, even though easy, can be boring and subject to mistakes, and it can take longer than expected.
If you have the numeric id of another user, who is going to replace the author or modifier of the article, the updates can be done through a SQL query.
Run the attached SQL statement first in a test environment, for example a cloned copy of the website, hosted on your workstation, using a bundle like Wampserver from https://wampserver.com/en. Make a backup of the content table before the test, in case something goes wrong.
The attached SQL script replaces the author of all articles created by the deleted original user, whose name and other details cannot be found from the users table in the database. The first SQL statement sets the user id of the new author. After that a CREATE statement creates a temporary table so that the article ids can be stored by the subsequent query, which finds all the articles where the author has been deleted and adds the article id to a temporary table.
The same pattern can be used to update the column 'modified_by'. Replace 'ep28r' with your own table prefix.
SET @author = 181;
DROP TEMPORARY TABLE IF EXISTS deleted_users;
CREATE TEMPORARY TABLE deleted_users (
`id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`)
SELECT c.id FROM ep28r_content c
LEFT JOIN ep28r_users u ON c.created_by = u.id
WHERE u.id IS NULL;
UPDATE ep28r_content c SET c.created_by = @author
WHERE c.id IN(SELECT d.id FROM deleted_users d);