X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2Fbackend%2FFileBackend.php;h=3cc902194544f61a9704c2a258c0925f9cfff79c;hb=a7e28d201191e7ca8a51d10140f3f84c266b197d;hp=81fbcedda6866a8aff94e0714ca279db1c199a2d;hpb=6b90f40da307b10d0d0e42ca396e45eef00a6c9c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index 81fbcedda6..3cc9021945 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -401,6 +401,7 @@ abstract class FileBackend { * * @param $ops Array Set of operations to execute * @return Status + * @since 1.20 */ final public function doQuickOperations( array $ops ) { if ( $this->isReadOnly() ) { @@ -414,9 +415,94 @@ abstract class FileBackend { /** * @see FileBackend::doQuickOperations() + * @since 1.20 */ abstract protected function doQuickOperationsInternal( array $ops ); + /** + * Same as doQuickOperations() except it takes a single operation. + * If you are doing a batch of operations, then use that function instead. + * + * @see FileBackend::doQuickOperations() + * + * @param $op Array Operation + * @return Status + * @since 1.20 + */ + final public function doQuickOperation( array $op ) { + return $this->doQuickOperations( array( $op ) ); + } + + /** + * Performs a single quick create operation. + * This sets $params['op'] to 'create' and passes it to doQuickOperation(). + * + * @see FileBackend::doQuickOperation() + * + * @param $params Array Operation parameters + * @return Status + * @since 1.20 + */ + final public function quickCreate( array $params ) { + return $this->doQuickOperation( array( 'op' => 'create' ) + $params ); + } + + /** + * Performs a single quick store operation. + * This sets $params['op'] to 'store' and passes it to doQuickOperation(). + * + * @see FileBackend::doQuickOperation() + * + * @param $params Array Operation parameters + * @return Status + * @since 1.20 + */ + final public function quickStore( array $params ) { + return $this->doQuickOperation( array( 'op' => 'store' ) + $params ); + } + + /** + * Performs a single quick copy operation. + * This sets $params['op'] to 'copy' and passes it to doQuickOperation(). + * + * @see FileBackend::doQuickOperation() + * + * @param $params Array Operation parameters + * @return Status + * @since 1.20 + */ + final public function quickCopy( array $params ) { + return $this->doQuickOperation( array( 'op' => 'copy' ) + $params ); + } + + /** + * Performs a single quick move operation. + * This sets $params['op'] to 'move' and passes it to doQuickOperation(). + * + * @see FileBackend::doQuickOperation() + * + * @param $params Array Operation parameters + * @return Status + * @since 1.20 + */ + final public function quickMove( array $params ) { + return $this->doQuickOperation( array( 'op' => 'move' ) + $params ); + } + + /** + * Performs a single quick delete operation. + * This sets $params['op'] to 'delete' and passes it to doQuickOperation(). + * + * @see FileBackend::doQuickOperation() + * + * @param $params Array Operation parameters + * @return Status + * @since 1.20 + */ + final public function quickDelete( array $params ) { + return $this->doQuickOperation( array( 'op' => 'delete' ) + $params ); + } + /** * Concatenate a list of storage files into a single file system file. * The target path should refer to a file that is already locked or @@ -794,6 +880,24 @@ abstract class FileBackend { return ScopedLock::factory( $this->lockManager, $paths, $type, $status ); } + /** + * Get an array of scoped locks needed for a batch of file operations. + * + * Normally, FileBackend::doOperations() handles locking, unless + * the 'nonLocking' param is passed in. This function is useful if you + * want the files to be locked for a broader scope than just when the + * files are changing. For example, if you need to update DB metadata, + * you may want to keep the files locked until finished. + * + * @see FileBackend::doOperations() + * + * @param $ops Array List of file operations to FileBackend::doOperations() + * @param $status Status Status to update on lock/unlock + * @return Array List of ScopedFileLocks or null values + * @since 1.20 + */ + abstract public function getScopedLocksForOps( array $ops, Status $status ); + /** * Get the root storage path of this backend. * All container paths are "subdirectories" of this path.