X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilebackend%2FFileOp.php;h=56a40738e6e503df4a4cca250d9dc162487f5971;hb=734ca2b4d2a1246fb0ea1e54b861ab423ab5e257;hp=83599434663a0faa06c736534835fb6036bdaccd;hpb=174f34a86de3162bc673fd3bc6bed815cccf0edc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filebackend/FileOp.php b/includes/filebackend/FileOp.php index 8359943466..56a40738e6 100644 --- a/includes/filebackend/FileOp.php +++ b/includes/filebackend/FileOp.php @@ -35,7 +35,7 @@ */ abstract class FileOp { /** @var array */ - protected $params = array(); + protected $params = []; /** @var FileBackendStore */ protected $backend; @@ -149,7 +149,7 @@ abstract class FileOp { * @return array */ final public static function newPredicates() { - return array( 'exists' => array(), 'sha1' => array() ); + return [ 'exists' => [], 'sha1' => [] ]; } /** @@ -158,7 +158,7 @@ abstract class FileOp { * @return array */ final public static function newDependencies() { - return array( 'read' => array(), 'write' => array() ); + return [ 'read' => [], 'write' => [] ]; } /** @@ -204,32 +204,32 @@ abstract class FileOp { */ final public function getJournalEntries( array $oPredicates, array $nPredicates ) { if ( !$this->doOperation ) { - return array(); // this is a no-op + return []; // this is a no-op } - $nullEntries = array(); - $updateEntries = array(); - $deleteEntries = array(); + $nullEntries = []; + $updateEntries = []; + $deleteEntries = []; $pathsUsed = array_merge( $this->storagePathsRead(), $this->storagePathsChanged() ); foreach ( array_unique( $pathsUsed ) as $path ) { - $nullEntries[] = array( // assertion for recovery + $nullEntries[] = [ // assertion for recovery 'op' => 'null', 'path' => $path, 'newSha1' => $this->fileSha1( $path, $oPredicates ) - ); + ]; } foreach ( $this->storagePathsChanged() as $path ) { if ( $nPredicates['sha1'][$path] === false ) { // deleted - $deleteEntries[] = array( + $deleteEntries[] = [ 'op' => 'delete', 'path' => $path, 'newSha1' => '' - ); + ]; } else { // created/updated - $updateEntries[] = array( + $updateEntries[] = [ 'op' => $this->fileExists( $path, $oPredicates ) ? 'update' : 'create', 'path' => $path, 'newSha1' => $nPredicates['sha1'][$path] - ); + ]; } } @@ -316,7 +316,7 @@ abstract class FileOp { * @return array (required params list, optional params list, list of params that are paths) */ protected function allowedParams() { - return array( array(), array(), array() ); + return [ [], [], [] ]; } /** @@ -326,7 +326,7 @@ abstract class FileOp { * @return array (required params list, optional params list) */ protected function setFlags( array $params ) { - return array( 'async' => $this->async ) + $params; + return [ 'async' => $this->async ] + $params; } /** @@ -335,7 +335,7 @@ abstract class FileOp { * @return array */ public function storagePathsRead() { - return array(); + return []; } /** @@ -344,7 +344,7 @@ abstract class FileOp { * @return array */ public function storagePathsChanged() { - return array(); + return []; } /** @@ -411,7 +411,7 @@ abstract class FileOp { if ( isset( $predicates['exists'][$source] ) ) { return $predicates['exists'][$source]; // previous op assures this } else { - $params = array( 'src' => $source, 'latest' => true ); + $params = [ 'src' => $source, 'latest' => true ]; return $this->backend->fileExists( $params ); } @@ -430,7 +430,7 @@ abstract class FileOp { } elseif ( isset( $predicates['exists'][$source] ) && !$predicates['exists'][$source] ) { return false; // previous op assures this } else { - $params = array( 'src' => $source, 'latest' => true ); + $params = [ 'src' => $source, 'latest' => true ]; return $this->backend->getFileSha1Base36( $params ); } @@ -468,11 +468,11 @@ abstract class FileOp { */ class CreateFileOp extends FileOp { protected function allowedParams() { - return array( - array( 'content', 'dst' ), - array( 'overwrite', 'overwriteSame', 'headers' ), - array( 'dst' ) - ); + return [ + [ 'content', 'dst' ], + [ 'overwrite', 'overwriteSame', 'headers' ], + [ 'dst' ] + ]; } protected function doPrecheck( array &$predicates ) { @@ -517,7 +517,7 @@ class CreateFileOp extends FileOp { } public function storagePathsChanged() { - return array( $this->params['dst'] ); + return [ $this->params['dst'] ]; } } @@ -527,11 +527,11 @@ class CreateFileOp extends FileOp { */ class StoreFileOp extends FileOp { protected function allowedParams() { - return array( - array( 'src', 'dst' ), - array( 'overwrite', 'overwriteSame', 'headers' ), - array( 'src', 'dst' ) - ); + return [ + [ 'src', 'dst' ], + [ 'overwrite', 'overwriteSame', 'headers' ], + [ 'src', 'dst' ] + ]; } protected function doPrecheck( array &$predicates ) { @@ -588,7 +588,7 @@ class StoreFileOp extends FileOp { } public function storagePathsChanged() { - return array( $this->params['dst'] ); + return [ $this->params['dst'] ]; } } @@ -598,11 +598,11 @@ class StoreFileOp extends FileOp { */ class CopyFileOp extends FileOp { protected function allowedParams() { - return array( - array( 'src', 'dst' ), - array( 'overwrite', 'overwriteSame', 'ignoreMissingSource', 'headers' ), - array( 'src', 'dst' ) - ); + return [ + [ 'src', 'dst' ], + [ 'overwrite', 'overwriteSame', 'ignoreMissingSource', 'headers' ], + [ 'src', 'dst' ] + ]; } protected function doPrecheck( array &$predicates ) { @@ -645,10 +645,10 @@ class CopyFileOp extends FileOp { $status = Status::newGood(); // nothing to do } elseif ( $this->params['src'] === $this->params['dst'] ) { // Just update the destination file headers - $headers = $this->getParam( 'headers' ) ?: array(); - $status = $this->backend->describeInternal( $this->setFlags( array( + $headers = $this->getParam( 'headers' ) ?: []; + $status = $this->backend->describeInternal( $this->setFlags( [ 'src' => $this->params['dst'], 'headers' => $headers - ) ) ); + ] ) ); } else { // Copy the file to the destination $status = $this->backend->copyInternal( $this->setFlags( $this->params ) ); @@ -658,11 +658,11 @@ class CopyFileOp extends FileOp { } public function storagePathsRead() { - return array( $this->params['src'] ); + return [ $this->params['src'] ]; } public function storagePathsChanged() { - return array( $this->params['dst'] ); + return [ $this->params['dst'] ]; } } @@ -672,11 +672,11 @@ class CopyFileOp extends FileOp { */ class MoveFileOp extends FileOp { protected function allowedParams() { - return array( - array( 'src', 'dst' ), - array( 'overwrite', 'overwriteSame', 'ignoreMissingSource', 'headers' ), - array( 'src', 'dst' ) - ); + return [ + [ 'src', 'dst' ], + [ 'overwrite', 'overwriteSame', 'ignoreMissingSource', 'headers' ], + [ 'src', 'dst' ] + ]; } protected function doPrecheck( array &$predicates ) { @@ -724,14 +724,14 @@ class MoveFileOp extends FileOp { } else { // Just delete the source as the destination file needs no changes $status = $this->backend->deleteInternal( $this->setFlags( - array( 'src' => $this->params['src'] ) + [ 'src' => $this->params['src'] ] ) ); } } elseif ( $this->params['src'] === $this->params['dst'] ) { // Just update the destination file headers - $headers = $this->getParam( 'headers' ) ?: array(); + $headers = $this->getParam( 'headers' ) ?: []; $status = $this->backend->describeInternal( $this->setFlags( - array( 'src' => $this->params['dst'], 'headers' => $headers ) + [ 'src' => $this->params['dst'], 'headers' => $headers ] ) ); } else { // Move the file to the destination @@ -742,11 +742,11 @@ class MoveFileOp extends FileOp { } public function storagePathsRead() { - return array( $this->params['src'] ); + return [ $this->params['src'] ]; } public function storagePathsChanged() { - return array( $this->params['src'], $this->params['dst'] ); + return [ $this->params['src'], $this->params['dst'] ]; } } @@ -756,7 +756,7 @@ class MoveFileOp extends FileOp { */ class DeleteFileOp extends FileOp { protected function allowedParams() { - return array( array( 'src' ), array( 'ignoreMissingSource' ), array( 'src' ) ); + return [ [ 'src' ], [ 'ignoreMissingSource' ], [ 'src' ] ]; } protected function doPrecheck( array &$predicates ) { @@ -795,7 +795,7 @@ class DeleteFileOp extends FileOp { } public function storagePathsChanged() { - return array( $this->params['src'] ); + return [ $this->params['src'] ]; } } @@ -805,7 +805,7 @@ class DeleteFileOp extends FileOp { */ class DescribeFileOp extends FileOp { protected function allowedParams() { - return array( array( 'src' ), array( 'headers' ), array( 'src' ) ); + return [ [ 'src' ], [ 'headers' ], [ 'src' ] ]; } protected function doPrecheck( array &$predicates ) { @@ -837,7 +837,7 @@ class DescribeFileOp extends FileOp { } public function storagePathsChanged() { - return array( $this->params['src'] ); + return [ $this->params['src'] ]; } }