filebackend: add idiom constant to FileBackend for null results
[lhc/web/wiklou.git] / includes / libs / filebackend / MemoryFileBackend.php
index 0341a2a..88b281e 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup FileBackend
  */
 
+use Wikimedia\AtEase\AtEase;
+
 /**
  * Simulation of a backend storage in memory.
  *
@@ -70,9 +72,9 @@ class MemoryFileBackend extends FileBackendStore {
                        return $status;
                }
 
-               MediaWiki\suppressWarnings();
+               AtEase::suppressWarnings();
                $data = file_get_contents( $params['src'] );
-               MediaWiki\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 false; // invalid path
                }
 
                if ( isset( $this->files[$src] ) ) {
@@ -168,7 +170,7 @@ class MemoryFileBackend extends FileBackendStore {
                        } 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'] ) ) {