Merge "Removed executeReadyPeriodicTasks() method"
[lhc/web/wiklou.git] / includes / filerepo / LocalRepo.php
index 96c8803..591d684 100644 (file)
@@ -49,7 +49,7 @@ class LocalRepo extends FileRepo {
 
        /**
         * @throws MWException
-        * @param array $row
+        * @param stdClass $row
         * @return LocalFile
         */
        function newFileFromRow( $row ) {
@@ -90,8 +90,8 @@ class LocalRepo extends FileRepo {
                foreach ( $storageKeys as $key ) {
                        $hashPath = $this->getDeletedHashPath( $key );
                        $path = "$root/$hashPath$key";
-                       $dbw->begin( __METHOD__ );
-                       // Check for usage in deleted/hidden files and pre-emptively
+                       $dbw->startAtomic( __METHOD__ );
+                       // Check for usage in deleted/hidden files and preemptively
                        // lock the key to avoid any future use until we are finished.
                        $deleted = $this->deletedFileHasKey( $key, 'lock' );
                        $hidden = $this->hiddenFileHasKey( $key, 'lock' );
@@ -106,7 +106,7 @@ class LocalRepo extends FileRepo {
                                wfDebug( __METHOD__ . ": $key still in use\n" );
                                $status->successCount++;
                        }
-                       $dbw->commit( __METHOD__ );
+                       $dbw->endAtomic( __METHOD__ );
                }
 
                return $status;
@@ -167,10 +167,10 @@ class LocalRepo extends FileRepo {
         * Checks if there is a redirect named as $title
         *
         * @param Title $title Title of file
-        * @return bool
+        * @return bool|Title
         */
        function checkRedirect( Title $title ) {
-               global $wgMemc;
+               $cache = ObjectCache::getMainWANInstance();
 
                $title = File::normalizeTitle( $title, 'exception' );
 
@@ -181,7 +181,7 @@ class LocalRepo extends FileRepo {
                } else {
                        $expiry = 86400; // has invalidation, 1 day
                }
-               $cachedValue = $wgMemc->get( $memcKey );
+               $cachedValue = $cache->get( $memcKey );
                if ( $cachedValue === ' ' || $cachedValue === '' ) {
                        // Does not exist
                        return false;
@@ -191,7 +191,7 @@ class LocalRepo extends FileRepo {
 
                $id = $this->getArticleID( $title );
                if ( !$id ) {
-                       $wgMemc->add( $memcKey, " ", $expiry );
+                       $cache->set( $memcKey, " ", $expiry );
 
                        return false;
                }
@@ -205,11 +205,11 @@ class LocalRepo extends FileRepo {
 
                if ( $row && $row->rd_namespace == NS_FILE ) {
                        $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title );
-                       $wgMemc->add( $memcKey, $targetTitle->getDBkey(), $expiry );
+                       $cache->set( $memcKey, $targetTitle->getDBkey(), $expiry );
 
                        return $targetTitle;
                } else {
-                       $wgMemc->add( $memcKey, '', $expiry );
+                       $cache->set( $memcKey, '', $expiry );
 
                        return false;
                }
@@ -370,7 +370,7 @@ class LocalRepo extends FileRepo {
         * SHA-1 content hash.
         *
         * @param string $hash A sha1 hash to look for
-        * @return array
+        * @return File[]
         */
        function findBySha1( $hash ) {
                $dbr = $this->getSlaveDB();
@@ -489,14 +489,15 @@ class LocalRepo extends FileRepo {
         * @return void
         */
        function invalidateImageRedirect( Title $title ) {
-               global $wgMemc;
+               $cache = ObjectCache::getMainWANInstance();
+
                $memcKey = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
                if ( $memcKey ) {
                        // Set a temporary value for the cache key, to ensure
                        // that this value stays purged long enough so that
                        // it isn't refreshed with a stale value due to a
                        // lagged slave.
-                       $wgMemc->set( $memcKey, ' PURGED', 12 );
+                       $cache->delete( $memcKey, 12 );
                }
        }