*Fix bug when using Mediawiki updater command line.
[lhc/web/wiklou.git] / maintenance / cleanupImages.php
index 57b36f7..d6ed5a7 100644 (file)
@@ -25,8 +25,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @author Brion Vibber <brion at pobox.com>
- * @package MediaWiki
- * @subpackage maintenance
+ * @addtogroup maintenance
  */
 
 require_once( 'commandLine.inc' );
@@ -67,8 +66,8 @@ class ImageCleanup extends TableCleanup {
                        return $this->progress( 1 );
                }
 
-               if( $title->getDbKey() !== $source ) {
-                       $munged = $title->getDbKey();
+               if( $title->getDBkey() !== $source ) {
+                       $munged = $title->getDBkey();
                        $this->log( "page $source ($munged) doesn't match self." );
                        $this->pokeFile( $source, $munged );
                        return $this->progress( 1 );
@@ -90,7 +89,10 @@ class ImageCleanup extends TableCleanup {
        }
        
        function filePath( $name ) {
-               return wfImageDir( $name ) . "/$name";
+               if ( !isset( $this->repo ) ) {
+                       $this->repo = RepoGroup::singleton()->getLocalRepo();
+               }
+               return $this->repo->getRootDirectory() . '/' . $this->repo->getHashPath( $name ) . $name;
        }
        
        function pokeFile( $orig, $new ) {
@@ -145,13 +147,14 @@ class ImageCleanup extends TableCleanup {
        }
        
        function buildSafeTitle( $name ) {
+               global $wgLegalTitleChars;
                $x = preg_replace_callback(
                        "/([^$wgLegalTitleChars])/",
-                       $name,
-                       array( $this, 'hexChar' ) );
+                       array( $this, 'hexChar' ),
+                       $name );
                
                $test = Title::makeTitleSafe( NS_IMAGE, $x );
-               if( is_null( $test ) || $test->getDbKey() !== $x ) {
+               if( is_null( $test ) || $test->getDBkey() !== $x ) {
                        $this->log( "Unable to generate safe title from '$name', got '$x'" );
                        return false;
                }
@@ -164,4 +167,4 @@ $wgUser->setName( 'Conversion script' );
 $caps = new ImageCleanup( !isset( $options['fix'] ) );
 $caps->cleanup();
 
-?>
+