Fix cleanupTitles.php
authorMax Semenik <maxsem.wiki@gmail.com>
Mon, 10 Jul 2017 22:07:07 +0000 (15:07 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Mon, 10 Jul 2017 22:07:07 +0000 (15:07 -0700)
It was failing in production with duplicate key error in
moveInconsistentPage(). Live-patching it to check for existence
for updates resolved the issues. Committing the fix now.

Change-Id: I1c0bf632b5040b44f5a49c8fb95779e7ed19dea9

maintenance/cleanupTitles.php

index ccc6406..50e17d8 100644 (file)
@@ -25,6 +25,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/cleanupTable.inc';
 
 /**
@@ -130,8 +132,11 @@ class TitleCleanup extends TableCleanup {
         * @param object $row
         * @param Title $title
         */
-       protected function moveInconsistentPage( $row, $title ) {
-               if ( $title->exists() || $title->getInterwiki() || !$title->canExist() ) {
+       protected function moveInconsistentPage( $row, Title $title ) {
+               if ( $title->exists( Title::GAID_FOR_UPDATE )
+                       || $title->getInterwiki()
+                       || !$title->canExist()
+               ) {
                        if ( $title->getInterwiki() || !$title->canExist() ) {
                                $prior = $title->getPrefixedDBkey();
                        } else {
@@ -179,7 +184,7 @@ class TitleCleanup extends TableCleanup {
                                ],
                                [ 'page_id' => $row->page_id ],
                                __METHOD__ );
-                       LinkCache::singleton()->clear();
+                       MediaWikiServices::getInstance()->getLinkCache()->clear();
                }
        }
 }