Manual:CleanupInvalidDbKeys.php

MediaWiki version:
1.29
Category:MediaWiki code#CleanupInvalidDbKeys.php

Details

cleanupInvalidDbKeys.php is a maintenance script that cleans up the title fields in various tables to remove entries that will be rejected by the constructor of TitleValue. This constructor throws an exception when invalid data is encountered, which will not normally occur on regular page views, but can happen on query special pages.

The script targets titles matching the regular expression /^_|[ \r\n\t]|_$/. Because any foreign key relationships involving these titles will already be broken, the titles are corrected to a valid version or the rows are deleted entirely, depending on the table.

Options

OptionDescriptionRequired
--fixActually clean up invalid titles. If this parameter is not specified, the script will report invalid titles but not clean them up.Optional
--tableThe table(s) to process. This option can be specified more than once (e.g. -t category -t watchlist). If not specified, all available tables will be processed.
Available tables are: page, redirect, archive, logging, protected_titles, category, recentchanges, watchlist, pagelinks, templatelinks, categorylinks
Optional

Usage

php maintenance/run.php cleanupInvalidDbKeys [ --fix| --table ]
In MediaWiki version 1.39.12 and earlier, you must invoke maintenance scripts using php maintenance/scriptName.php instead of php maintenance/run.php scriptName.
Terminal
Terminal

See also

Category:Maintenance scripts Category:Database maintenance scripts
Category:Database maintenance scripts Category:Maintenance scripts Category:MediaWiki code