Merge "Move User::getAllRights to PermissionManager."
[lhc/web/wiklou.git] / includes / libs / filebackend / SwiftFileBackend.php
index a1b2460..e576c64 100644 (file)
@@ -22,6 +22,8 @@
  * @author Russ Nelson
  */
 
+use Wikimedia\AtEase\AtEase;
+
 /**
  * @brief Class for an OpenStack Swift (or Ceph RGW) based file backend.
  *
@@ -326,9 +328,9 @@ class SwiftFileBackend extends FileBackendStore {
                        return $status;
                }
 
-               Wikimedia\suppressWarnings();
+               AtEase::suppressWarnings();
                $sha1Hash = sha1_file( $params['src'] );
-               Wikimedia\restoreWarnings();
+               AtEase::restoreWarnings();
                if ( $sha1Hash === false ) { // source doesn't exist?
                        $status->fatal( 'backend-fail-store', $params['src'], $params['dst'] );
 
@@ -591,7 +593,7 @@ class SwiftFileBackend extends FileBackendStore {
                $stat = $this->getContainerStat( $fullCont );
                if ( is_array( $stat ) ) {
                        return $status; // already there
-               } elseif ( $stat === null ) {
+               } elseif ( $stat === self::UNKNOWN ) {
                        $status->fatal( 'backend-fail-internal', $this->name );
                        $this->logger->error( __METHOD__ . ': cannot get container stat' );
 
@@ -830,7 +832,7 @@ class SwiftFileBackend extends FileBackendStore {
                        return ( count( $status->value ) ) > 0;
                }
 
-               return null; // error
+               return self::UNKNOWN; // error
        }
 
        /**
@@ -1150,7 +1152,7 @@ class SwiftFileBackend extends FileBackendStore {
                        // Get source file extension
                        $ext = FileBackend::extensionFromPath( $path );
                        // Create a new temporary file...
-                       $tmpFile = TempFSFile::factory( 'localcopy_', $ext, $this->tmpDirectory );
+                       $tmpFile = $this->tmpFileFactory->newTempFSFile( 'localcopy_', $ext );
                        if ( $tmpFile ) {
                                $handle = fopen( $tmpFile->getPath(), 'wb' );
                                if ( $handle ) {
@@ -1399,7 +1401,7 @@ class SwiftFileBackend extends FileBackendStore {
                if ( !$this->containerStatCache->hasField( $container, 'stat' ) ) {
                        $auth = $this->getAuthentication();
                        if ( !$auth ) {
-                               return null;
+                               return self::UNKNOWN;
                        }
 
                        list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( [
@@ -1425,7 +1427,7 @@ class SwiftFileBackend extends FileBackendStore {
                                $this->onError( null, __METHOD__,
                                        [ 'cont' => $container ], $rerr, $rcode, $rdesc );
 
-                               return null;
+                               return self::UNKNOWN;
                        }
                }
 
@@ -1597,7 +1599,7 @@ class SwiftFileBackend extends FileBackendStore {
                                $stats[$path] = false;
                                continue; // invalid storage path
                        } elseif ( !$auth ) {
-                               $stats[$path] = null;
+                               $stats[$path] = self::UNKNOWN;
                                continue;
                        }
 
@@ -1607,7 +1609,7 @@ class SwiftFileBackend extends FileBackendStore {
                                $stats[$path] = false;
                                continue; // ok, nothing to do
                        } elseif ( !is_array( $cstat ) ) {
-                               $stats[$path] = null;
+                               $stats[$path] = self::UNKNOWN;
                                continue;
                        }
 
@@ -1640,7 +1642,7 @@ class SwiftFileBackend extends FileBackendStore {
                        } elseif ( $rcode === 404 ) {
                                $stat = false;
                        } else {
-                               $stat = null;
+                               $stat = self::UNKNOWN;
                                $this->onError( null, __METHOD__, $params, $rerr, $rcode, $rdesc );
                        }
                        $stats[$path] = $stat;