FindOrphanedFiles cleanups
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 4 Nov 2015 22:04:56 +0000 (14:04 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 4 Nov 2015 22:04:56 +0000 (14:04 -0800)
* Avoid empty DB list errors for some batches
* Use more convenient cannonical URLs

Change-Id: I37f59e0747525603828897196eabd6c64740aa02

maintenance/findOrphanedFiles.php

index 2ee406f..eac277a 100644 (file)
@@ -105,12 +105,12 @@ class FindOrphanedFiles extends Maintenance {
                                        $dbr->selectSQLText(
                                                'image',
                                                array( 'name' => 'img_name' ),
                                        $dbr->selectSQLText(
                                                'image',
                                                array( 'name' => 'img_name' ),
-                                               array( 'img_name' => $imgIN )
+                                               $imgIN ? array( 'img_name' => $imgIN ) : '1=0'
                                        ),
                                        $dbr->selectSQLText(
                                                'oldimage',
                                                array( 'name' => 'oi_archive_name' ),
                                        ),
                                        $dbr->selectSQLText(
                                                'oldimage',
                                                array( 'name' => 'oi_archive_name' ),
-                                               $dbr->makeList( $oiWheres, LIST_OR )
+                                               $oiWheres ? $dbr->makeList( $oiWheres, LIST_OR ) : '1=0'
                                        )
                                ),
                                true // UNION ALL (performance)
                                        )
                                ),
                                true // UNION ALL (performance)
@@ -132,7 +132,7 @@ class FindOrphanedFiles extends Maintenance {
                        } else {
                                $file = $repo->newFile( $name );
                        }
                        } else {
                                $file = $repo->newFile( $name );
                        }
-                       $this->output( $name . "\n" . $file->getUrl() . "\n\n" );
+                       $this->output( $name . "\n" . $file->getCanonicalUrl() . "\n\n" );
                }
        }
 }
                }
        }
 }