*/
class MemoryFileBackend extends FileBackendStore {
/** @var array Map of (file path => (data,mtime) */
- protected $files = array();
+ protected $files = [];
+
+ public function getFeatures() {
+ return self::ATTR_UNICODE_PATHS;
+ }
public function isPathUsableInternal( $storagePath ) {
return true;
}
protected function doCreateInternal( array $params ) {
- $status = Status::newGood();
+ $status = $this->newStatus();
$dst = $this->resolveHashKey( $params['dst'] );
if ( $dst === null ) {
return $status;
}
- $this->files[$dst] = array(
+ $this->files[$dst] = [
'data' => $params['content'],
'mtime' => wfTimestamp( TS_MW, time() )
- );
+ ];
return $status;
}
protected function doStoreInternal( array $params ) {
- $status = Status::newGood();
+ $status = $this->newStatus();
$dst = $this->resolveHashKey( $params['dst'] );
if ( $dst === null ) {
return $status;
}
- $this->files[$dst] = array(
+ $this->files[$dst] = [
'data' => $data,
'mtime' => wfTimestamp( TS_MW, time() )
- );
+ ];
return $status;
}
protected function doCopyInternal( array $params ) {
- $status = Status::newGood();
+ $status = $this->newStatus();
$src = $this->resolveHashKey( $params['src'] );
if ( $src === null ) {
return $status;
}
- $this->files[$dst] = array(
+ $this->files[$dst] = [
'data' => $this->files[$src]['data'],
'mtime' => wfTimestamp( TS_MW, time() )
- );
+ ];
return $status;
}
protected function doDeleteInternal( array $params ) {
- $status = Status::newGood();
+ $status = $this->newStatus();
$src = $this->resolveHashKey( $params['src'] );
if ( $src === null ) {
}
if ( isset( $this->files[$src] ) ) {
- return array(
+ return [
'mtime' => $this->files[$src]['mtime'],
'size' => strlen( $this->files[$src]['data'] ),
- );
+ ];
}
return false;
}
protected function doGetLocalCopyMulti( array $params ) {
- $tmpFiles = array(); // (path => TempFSFile)
+ $tmpFiles = []; // (path => TempFSFile)
foreach ( $params['srcs'] as $srcPath ) {
$src = $this->resolveHashKey( $srcPath );
if ( $src === null || !isset( $this->files[$src] ) ) {
return $tmpFiles;
}
- protected function doStreamFile( array $params ) {
- $status = Status::newGood();
-
- $src = $this->resolveHashKey( $params['src'] );
- if ( $src === null || !isset( $this->files[$src] ) ) {
- $status->fatal( 'backend-fail-stream', $params['src'] );
-
- return $status;
- }
-
- print $this->files[$src]['data'];
-
- return $status;
- }
-
protected function doDirectoryExists( $container, $dir, array $params ) {
$prefix = rtrim( "$container/$dir", '/' ) . '/';
foreach ( $this->files as $path => $data ) {
}
public function getDirectoryListInternal( $container, $dir, array $params ) {
- $dirs = array();
+ $dirs = [];
$prefix = rtrim( "$container/$dir", '/' ) . '/';
$prefixLen = strlen( $prefix );
foreach ( $this->files as $path => $data ) {
}
public function getFileListInternal( $container, $dir, array $params ) {
- $files = array();
+ $files = [];
$prefix = rtrim( "$container/$dir", '/' ) . '/';
$prefixLen = strlen( $prefix );
foreach ( $this->files as $path => $data ) {