Manual:cleanupUsersWithNoId.php

Other languages:
English • ‎polski • ‎日本語 • ‎한국어

DetailsEdit

cleanupUsersWithNoId.php is a maintenance script that cleans up tables that have valid usernames with no user ID. It should once be run in wikis that contain imported revisions or global blocks via the CentralAuth extension.

UsageEdit

php cleanupUsersWithNoId.php --prefix=prefix [--table=table] [--assign]
Option/Parameter Description
--prefix Interwiki prefix to apply to the usernames. This is a required parameter.
--table Only clean up this table. The name of one single table can be provided here. If not provided, all affected tables will be cleaned up. These are: revision, archive, logging, image, oldimage, filearchive, ipblocks and recentchanges.
--assign Assign edits to existing local users if they exist.
--conf The configuration file or LocalSettings.php.

ExampleEdit

php cleanupUsersWithNoId.php --prefix=* --table=revision

This will only clean up the revision table.

If you receive the message 'CleanupUsersWithNoId' already logged as completed, then use --force option.

php cleanupUsersWithNoId.php --force --prefix=* --table=revision

HelpEdit

php cleanupUsersWithNoId.php --help

Cleans up tables that have valid usernames with no user ID

Usage: php cleanupUsersWithNoId.php [--assign|--batch-size|--conf|--dbgroupdefault|--dbpass|--dbuser|--force|--globals|--help|--memory-limit|--mwdebug|--prefix|--profiler|--quiet|--server|--table|--wiki]

Generic maintenance parameters:
    --help (-h): Display this help message
    --quiet (-q): Whether to suppress non-error output
    --conf: Location of LocalSettings.php, if not default
    --wiki: For specifying the wiki ID
    --globals: Output globals at the end of processing for debugging
    --memory-limit: Set a specific memory limit for the script, "max"
        for no limit or "default" to avoid changing it
    --server: The protocol and server name to use in URLs, e.g.
        http://en.wikipedia.org. This is sometimes necessary because server name
        detection may fail in command line scripts.
    --profiler: Profiler output format (usually "text")
    --mwdebug: Enable built-in MediaWiki development settings

Script dependant parameters:
    --dbuser: The DB user to use for this script
    --dbpass: The password to use for this script
    --dbgroupdefault: The default DB group to use.
    --batch-size: Run this many operations per batch, default: 100

Script specific parameters:
    --assign: Assign edits to existing local users if they exist
    --force: Run the update even if it was completed already
    --prefix (-p): Interwiki prefix to apply to the usernames
    --table: Only clean up this table

Spam CleanupEdit

Manual cleanup after a spammer got in may result in thousands of messages like the following.

User name "Awpgkcm9ly0hjqagqrpl" is usable, cannot create an anonymous
actor for it. Run maintenance/cleanupUsersWithNoId.php to fix this
situation.

The message is due to a user's name in the logging table, but not in the user table. The name may be missing from the user table because the Wiki admin deleted the spammer accounts en masse from the user table.

You can use the following query in MySQL to delete the log entries that correspond to the missing spam accounts. In the query below mywiki_user and mywiki_logging are the user and logging tables with your site's prefix. The prefix mywiki_ was used as an example, but you should change it to your site's prefix.

DELETE FROM mywiki_logging
WHERE NOT EXISTS(SELECT NULL
    FROM mywiki_user users
    WHERE users.user_name = log_user_text);