Make FindOrphanedFiles handle bad file titles
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 5 Nov 2015 04:19:17 +0000 (20:19 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 5 Nov 2015 04:19:17 +0000 (20:19 -0800)
Change-Id: Idb926097b6159c9c442ee6f427f1da60c5c5d2eb

maintenance/findOrphanedFiles.php

index a1e274c..41650bd 100644 (file)
@@ -136,7 +136,11 @@ class FindOrphanedFiles extends Maintenance {
                foreach ( array_diff( $curNames, $curNamesFound ) as $name ) {
                        $file = $repo->newFile( $name );
                        // Print name and public URL to ease recovery
-                       $this->output( $name . "\n" . $file->getCanonicalUrl() . "\n\n" );
+                       if ( $file ) {
+                               $this->output( $name . "\n" . $file->getCanonicalUrl() . "\n\n" );
+                       } else {
+                               $this->error( "Cannot get URL for bad file title '$name'" );
+                       }
                }
 
                foreach ( array_diff( $oldNames, $oldNamesFound ) as $name ) {