Move checkRedirect() from FileRepo to LocalRepo, leaving only a stub behind. It's...
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 20 Apr 2009 03:06:49 +0000 (03:06 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 20 Apr 2009 03:06:49 +0000 (03:06 +0000)
includes/filerepo/FileRepo.php
includes/filerepo/LocalRepo.php

index aaf5486..4176d3a 100644 (file)
@@ -518,47 +518,14 @@ abstract class FileRepo {
        function cleanupDeletedBatch( $storageKeys ) {}
 
        /**
-        * Checks if there is a redirect named as $title
+        * Checks if there is a redirect named as $title. If there is, return the
+        * title object. If not, return false.
+        * STUB
         *
         * @param Title $title Title of image
         */
        function checkRedirect( $title ) {
-               global $wgMemc;
-
-               if( is_string( $title ) ) {
-                       $title = Title::newFromTitle( $title );
-               }
-               if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) {
-                       $title = Title::makeTitle( NS_FILE, $title->getText() );
-               }
-
-               $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
-               $cachedValue = $wgMemc->get( $memcKey );
-               if( $cachedValue ) {
-                       return Title::newFromDbKey( $cachedValue );
-               } elseif( $cachedValue == ' ' ) { # FIXME: ugly hack, but BagOStuff caching seems to be weird and return false if !cachedValue, not only if it doesn't exist
-                       return false;
-               }
-
-               $id = $this->getArticleID( $title );
-               if( !$id ) {
-                       $wgMemc->set( $memcKey, " ", 9000 );
-                       return false;
-               }
-               $dbr = $this->getSlaveDB();
-               $row = $dbr->selectRow(
-                       'redirect',
-                       array( 'rd_title', 'rd_namespace' ),
-                       array( 'rd_from' => $id ),
-                       __METHOD__
-               );
-
-               if( $row ) $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title );
-               $wgMemc->set( $memcKey, ($row ? $targetTitle->getPrefixedDBkey() : " "), 9000 );
-               if( !$row ) {
-                       return false;
-               }
-               return $targetTitle;
+               return false;
        }
 
        /**
index 4014699..c679dd9 100644 (file)
@@ -67,6 +67,51 @@ class LocalRepo extends FSRepo {
                }
                return $status;
        }
+       
+       /**
+        * Checks if there is a redirect named as $title
+        *
+        * @param Title $title Title of image
+        */
+       function checkRedirect( $title ) {
+               global $wgMemc;
+
+               if( is_string( $title ) ) {
+                       $title = Title::newFromTitle( $title );
+               }
+               if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) {
+                       $title = Title::makeTitle( NS_FILE, $title->getText() );
+               }
+
+               $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
+               $cachedValue = $wgMemc->get( $memcKey );
+               if( $cachedValue ) {
+                       return Title::newFromDbKey( $cachedValue );
+               } elseif( $cachedValue == ' ' ) { # FIXME: ugly hack, but BagOStuff caching seems to be weird and return false if !cachedValue, not only if it doesn't exist
+                       return false;
+               }
+
+               $id = $this->getArticleID( $title );
+               if( !$id ) {
+                       $wgMemc->set( $memcKey, " ", 9000 );
+                       return false;
+               }
+               $dbr = $this->getSlaveDB();
+               $row = $dbr->selectRow(
+                       'redirect',
+                       array( 'rd_title', 'rd_namespace' ),
+                       array( 'rd_from' => $id ),
+                       __METHOD__
+               );
+
+               if( $row ) $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title );
+               $wgMemc->set( $memcKey, ($row ? $targetTitle->getPrefixedDBkey() : " "), 9000 );
+               if( !$row ) {
+                       return false;
+               }
+               return $targetTitle;
+       }
+
 
        /**
         * Function link Title::getArticleID().