X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Ffilebackend%2FMemoryFileBackend.php;h=f3bbecb8141cce657c50a3f432ebb2c1b1749cc5;hp=548c85c85d5369ada31358d99bebb40e41cdfa60;hb=e390198c4e4be7632b01173e42050061f1cc346a;hpb=ee56f00ddf0609082f8ae9a4dc3e6e1b6f54ddfd diff --git a/includes/libs/filebackend/MemoryFileBackend.php b/includes/libs/filebackend/MemoryFileBackend.php index 548c85c85d..f3bbecb814 100644 --- a/includes/libs/filebackend/MemoryFileBackend.php +++ b/includes/libs/filebackend/MemoryFileBackend.php @@ -21,6 +21,8 @@ * @ingroup FileBackend */ +use Wikimedia\AtEase\AtEase; + /** * Simulation of a backend storage in memory. * @@ -39,7 +41,7 @@ class MemoryFileBackend extends FileBackendStore { } public function isPathUsableInternal( $storagePath ) { - return true; + return ( $this->resolveHashKey( $storagePath ) !== null ); } protected function doCreateInternal( array $params ) { @@ -70,9 +72,9 @@ class MemoryFileBackend extends FileBackendStore { return $status; } - Wikimedia\suppressWarnings(); + AtEase::suppressWarnings(); $data = file_get_contents( $params['src'] ); - Wikimedia\restoreWarnings(); + AtEase::restoreWarnings(); if ( $data === false ) { // source doesn't exist? $status->fatal( 'backend-fail-store', $params['src'], $params['dst'] ); @@ -146,7 +148,7 @@ class MemoryFileBackend extends FileBackendStore { protected function doGetFileStat( array $params ) { $src = $this->resolveHashKey( $params['src'] ); if ( $src === null ) { - return null; + return self::$RES_ERROR; // invalid path } if ( isset( $this->files[$src] ) ) { @@ -156,23 +158,25 @@ class MemoryFileBackend extends FileBackendStore { ]; } - return false; + return self::$RES_ABSENT; } protected function doGetLocalCopyMulti( array $params ) { $tmpFiles = []; // (path => TempFSFile) foreach ( $params['srcs'] as $srcPath ) { $src = $this->resolveHashKey( $srcPath ); - if ( $src === null || !isset( $this->files[$src] ) ) { - $fsFile = null; + if ( $src === null ) { + $fsFile = self::$RES_ERROR; + } elseif ( !isset( $this->files[$src] ) ) { + $fsFile = self::$RES_ABSENT; } else { // Create a new temporary file with the same extension... $ext = FileBackend::extensionFromPath( $src ); - $fsFile = TempFSFile::factory( 'localcopy_', $ext, $this->tmpDirectory ); + $fsFile = $this->tmpFileFactory->newTempFSFile( 'localcopy_', $ext ); if ( $fsFile ) { $bytes = file_put_contents( $fsFile->getPath(), $this->files[$src]['data'] ); if ( $bytes !== strlen( $this->files[$src]['data'] ) ) { - $fsFile = null; + $fsFile = self::$RES_ERROR; } } }