r44646 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44645‎ | r44646 | r44647 >
Date:02:33, 16 December 2008
Author:vyznev
Status:ok
Tags:
Comment:
Followup to r44641: Only skip file pages that actually have a corresponding file.
Modified paths:
  • /trunk/phase3/maintenance/cleanupTitles.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/cleanupTitles.php
@@ -41,11 +41,6 @@
4242 }
4343
4444 function processPage( $row ) {
45 - if( $row->page_namespace == NS_FILE ) {
46 - // use cleanupImages.php for file pages
47 - return $this->progress( 0 );
48 - }
49 -
5045 $current = Title::makeTitle( $row->page_namespace, $row->page_title );
5146 $display = $current->getPrefixedText();
5247
@@ -53,19 +48,30 @@
5449
5550 $title = Title::newFromText( $verified );
5651
57 - if( is_null( $title ) ) {
 52+ if( !is_null( $title ) && $title->equals( $current ) ) {
 53+ return $this->progress( 0 ); // all is fine
 54+ }
 55+
 56+ if( $row->page_namespace == NS_FILE && $this->fileExists( $row->page_title ) ) {
 57+ $this->log( "file $row->page_title needs cleanup, please run cleanupImages.php." );
 58+ return $this->progress( 0 );
 59+ } elseif( is_null( $title ) ) {
5860 $this->log( "page $row->page_id ($display) is illegal." );
5961 $this->moveIllegalPage( $row );
6062 return $this->progress( 1 );
61 - }
62 -
63 - if( !$title->equals( $current ) ) {
 63+ } else {
6464 $this->log( "page $row->page_id ($display) doesn't match self." );
6565 $this->moveInconsistentPage( $row, $title );
6666 return $this->progress( 1 );
6767 }
 68+ }
6869
69 - $this->progress( 0 );
 70+ function fileExists( $name ) {
 71+ // XXX: Doesn't actually check for file existence, just presence of image record.
 72+ // This is reasonable, since cleanupImages.php only iterates over the image table.
 73+ $dbr = wfGetDB( DB_SLAVE );
 74+ $row = $dbr->selectRow( 'image', array( 'img_name' ), array( 'img_name' => $name ), __METHOD__ );
 75+ return $row !== false;
7076 }
7177
7278 function moveIllegalPage( $row ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44641Make cleanupTitles.php skip file pages (a bit late to fix that now, but oh we...vyznev00:34, 16 December 2008

Status & tagging log