Index: trunk/phase3/maintenance/cleanupTitles.php |
— | — | @@ -41,11 +41,6 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | function processPage( $row ) { |
45 | | - if( $row->page_namespace == NS_FILE ) { |
46 | | - // use cleanupImages.php for file pages |
47 | | - return $this->progress( 0 ); |
48 | | - } |
49 | | - |
50 | 45 | $current = Title::makeTitle( $row->page_namespace, $row->page_title ); |
51 | 46 | $display = $current->getPrefixedText(); |
52 | 47 | |
— | — | @@ -53,19 +48,30 @@ |
54 | 49 | |
55 | 50 | $title = Title::newFromText( $verified ); |
56 | 51 | |
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 ) ) { |
58 | 60 | $this->log( "page $row->page_id ($display) is illegal." ); |
59 | 61 | $this->moveIllegalPage( $row ); |
60 | 62 | return $this->progress( 1 ); |
61 | | - } |
62 | | - |
63 | | - if( !$title->equals( $current ) ) { |
| 63 | + } else { |
64 | 64 | $this->log( "page $row->page_id ($display) doesn't match self." ); |
65 | 65 | $this->moveInconsistentPage( $row, $title ); |
66 | 66 | return $this->progress( 1 ); |
67 | 67 | } |
| 68 | + } |
68 | 69 | |
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; |
70 | 76 | } |
71 | 77 | |
72 | 78 | function moveIllegalPage( $row ) { |