Merge "[FileBackend] Avoid infinite loops when populating missing metadata in Swift."
authorReedy <reedy@wikimedia.org>
Wed, 16 May 2012 01:51:34 +0000 (01:51 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 16 May 2012 01:51:34 +0000 (01:51 +0000)
includes/filerepo/backend/SwiftFileBackend.php

index 0def61f..1eb8a34 100644 (file)
@@ -612,7 +612,8 @@ class SwiftFileBackend extends FileBackendStore {
                $status = Status::newGood();
                $scopeLockS = $this->getScopedFileLocks( array( $path ), LockManager::LOCK_UW, $status );
                if ( $status->isOK() ) {
-                       $tmpFile = $this->getLocalCopy( array( 'src' => $path, 'latest' => 1 ) );
+                       # Do not stat the file in getLocalCopy() to avoid infinite loops
+                       $tmpFile = $this->getLocalCopy( array( 'src' => $path, 'latest' => 1, 'nostat' => 1 ) );
                        if ( $tmpFile ) {
                                $hash = $tmpFile->getSha1Base36();
                                if ( $hash !== false ) {
@@ -848,7 +849,8 @@ class SwiftFileBackend extends FileBackendStore {
                        return null;
                }
 
-               if ( !$this->fileExists( $params ) ) {
+               # Check the recursion guard to avoid loops when filling metadata
+               if ( empty( $params['nostat'] ) && !$this->fileExists( $params ) ) {
                        return null;
                }