broken, the titles are corrected to a valid version or the rows are deleted
entirely, depending on the table.
broken, the titles are corrected to a valid version or the rows are deleted
entirely, depending on the table.
- $this->output( 'Done! Cleaned up invalid DB keys on ' . wfWikiID() . "!\n" );
+ $this->outputStatus( 'Done!' );
+ if ( $this->hasOption( 'fix' ) ) {
+ $this->outputStatus( ' Cleaned up invalid DB keys on ' . wfWikiID() . "!\n" );
+ }
// Do all the select queries on the replicas, as they are slow (they use
// unanchored LIKEs). Naturally this could cause problems if rows are
// Do all the select queries on the replicas, as they are slow (they use
// unanchored LIKEs). Naturally this could cause problems if rows are
// The REGEXP operator is not cross-DBMS, so we have to use lots of LIKEs
[ $dbr->makeList( [
$titleField . $dbr->buildLike( $percent, ' ', $percent ),
// The REGEXP operator is not cross-DBMS, so we have to use lots of LIKEs
[ $dbr->makeList( [
$titleField . $dbr->buildLike( $percent, ' ', $percent ),
- $titleField . $dbr->buildLike( $percent, '\r', $percent ),
- $titleField . $dbr->buildLike( $percent, '\n', $percent ),
- $titleField . $dbr->buildLike( $percent, '\t', $percent ),
+ $titleField . $dbr->buildLike( $percent, "\r", $percent ),
+ $titleField . $dbr->buildLike( $percent, "\n", $percent ),
+ $titleField . $dbr->buildLike( $percent, "\t", $percent ),
$titleField . $dbr->buildLike( '_', $percent ),
$titleField . $dbr->buildLike( $percent, '_' ),
], LIST_OR ) ],
__METHOD__,
$titleField . $dbr->buildLike( '_', $percent ),
$titleField . $dbr->buildLike( $percent, '_' ),
], LIST_OR ) ],
__METHOD__,
// This shouldn't happen on production wikis, and we already have a script
// to handle 'page' rows anyway, so just notify the user and let them decide
// what to do next.
// This shouldn't happen on production wikis, and we already have a script
// to handle 'page' rows anyway, so just notify the user and let them decide
// what to do next.
IMPORTANT: This script does not fix invalid entries in the $table table.
Consider repairing these rows, and rows in related tables, by hand.
You may like to run, or borrow logic from, the cleanupTitles.php script.
IMPORTANT: This script does not fix invalid entries in the $table table.
Consider repairing these rows, and rows in related tables, by hand.
You may like to run, or borrow logic from, the cleanupTitles.php script.
// to the page_title field are already broken, so this will just make sure
// users can still access the log entries/deleted revisions from the interface
// using a valid page title.
// to the page_title field are already broken, so this will just make sure
// users can still access the log entries/deleted revisions from the interface
// using a valid page title.
"Updating these rows, setting $titleField to the closest valid DB key...\n" );
$affectedRowCount = 0;
foreach ( $res as $row ) {
"Updating these rows, setting $titleField to the closest valid DB key...\n" );
$affectedRowCount = 0;
foreach ( $res as $row ) {
// Since these broken titles can't exist, there's really nothing to watch,
// nothing can be categorised in them, and they can't have been changed
// recently, so we can just remove these rows.
// Since these broken titles can't exist, there's really nothing to watch,
// nothing can be categorised in them, and they can't have been changed
// recently, so we can just remove these rows.
break;
case 'protected_titles':
// Since these broken titles can't exist, there's really nothing to protect,
// so we can just remove these rows. Made more complicated by this table
// not having an ID field
break;
case 'protected_titles':
// Since these broken titles can't exist, there's really nothing to protect,
// so we can just remove these rows. Made more complicated by this table
// not having an ID field
// Update links tables for each page where these bogus links are supposedly
// located. If the invalid rows don't go away after these jobs go through,
// they're probably being added by a buggy hook.
// Update links tables for each page where these bogus links are supposedly
// located. If the invalid rows don't go away after these jobs go through,
// they're probably being added by a buggy hook.