Manual:CleanupInvalidDbKeys.php

Details
cleanupInvalidDbKeys.php is a 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. 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.