Manual:cleanupInvalidDbKeys.php
Appearance
MediaWiki version: | ≥ 1.29 |
MediaWiki file: cleanupInvalidDbKeys.php | |
---|---|
Location: | maintenance/ |
Source code: | master • 1.42.3 • 1.41.4 • 1.39.10 |
Classes: | CleanupInvalidDbKeys |
Details
[edit]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
[edit]Option | Description | Required |
---|---|---|
--fix | Actually clean up invalid titles. If this parameter is not specified, the script will report invalid titles but not clean them up. | Optional |
--table | The 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
[edit]php maintenance/cleanupInvalidDbKeys.php [ --fix| --table ]
Terminal
$ php maintenance/cleanupInvalidDbKeys.php --table page --table logging *** Looking for invalid page_title entries in page... Looking for invalid page_title entries in page... *** Number of invalid rows: 3 Number of invalid rows: 3 *** Looking for invalid log_title entries in logging... Looking for invalid log_title entries in logging... *** Number of invalid rows: 8 Number of invalid rows: 8 *** Done! Done!%
Terminal
$ php maintenance/cleanupInvalidDbKeys.php -t page -t logging --fix *** Looking for invalid page_title entries in page... Looking for invalid page_title entries in page... *** Number of invalid rows: 3 Number of invalid rows: 3 *** Looking for invalid log_title entries in logging... Looking for invalid log_title entries in logging... *** Number of invalid rows: 8 Number of invalid rows: 8 *** Done! Done!*** Cleaned up invalid DB keys on mw136-en_! Cleaned up invalid DB keys on mw136-en_!