From d0fc7d5d89ef926a7f5ca492a1e49cffe96ad8f3 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 19 Jan 2012 02:24:49 +0000 Subject: [PATCH] Renamed 'overwriteDest' FileBackend operation parameter to just 'overwrite', which is shorter and more consistent with 'overwriteSame' --- includes/filerepo/FileRepo.php | 2 +- includes/filerepo/backend/FSFileBackend.php | 8 ++++---- includes/filerepo/backend/FileBackend.php | 18 +++++++++--------- includes/filerepo/backend/FileOp.php | 18 +++++++++--------- includes/filerepo/backend/SwiftFileBackend.php | 6 +++--- includes/filerepo/file/File.php | 2 +- .../includes/filerepo/FileBackendTest.php | 18 +++++++++--------- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 78109b61c3..7e92b4db12 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -687,7 +687,7 @@ class FileRepo { 'op' => $opName, 'src' => $srcPath, 'dst' => $dstPath, - 'overwriteDest' => $flags & self::OVERWRITE, + 'overwrite' => $flags & self::OVERWRITE, 'overwriteSame' => $flags & self::OVERWRITE_SAME, ); } diff --git a/includes/filerepo/backend/FSFileBackend.php b/includes/filerepo/backend/FSFileBackend.php index a01f846e34..dc81c48f1c 100644 --- a/includes/filerepo/backend/FSFileBackend.php +++ b/includes/filerepo/backend/FSFileBackend.php @@ -114,7 +114,7 @@ class FSFileBackend extends FileBackend { } if ( file_exists( $dest ) ) { - if ( !empty( $params['overwriteDest'] ) ) { + if ( !empty( $params['overwrite'] ) ) { wfSuppressWarnings(); $ok = unlink( $dest ); wfRestoreWarnings(); @@ -160,7 +160,7 @@ class FSFileBackend extends FileBackend { } if ( file_exists( $dest ) ) { - if ( !empty( $params['overwriteDest'] ) ) { + if ( !empty( $params['overwrite'] ) ) { wfSuppressWarnings(); $ok = unlink( $dest ); wfRestoreWarnings(); @@ -206,7 +206,7 @@ class FSFileBackend extends FileBackend { } if ( file_exists( $dest ) ) { - if ( !empty( $params['overwriteDest'] ) ) { + if ( !empty( $params['overwrite'] ) ) { // Windows does not support moving over existing files if ( wfIsWindows() ) { wfSuppressWarnings(); @@ -278,7 +278,7 @@ class FSFileBackend extends FileBackend { } if ( file_exists( $dest ) ) { - if ( !empty( $params['overwriteDest'] ) ) { + if ( !empty( $params['overwrite'] ) ) { wfSuppressWarnings(); $ok = unlink( $dest ); wfRestoreWarnings(); diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index 9fc15b50fc..636b054518 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -98,7 +98,7 @@ abstract class FileBackendBase { * 'op' => 'create', * 'dst' => , * 'content' => , - * 'overwriteDest' => , + * 'overwrite' => , * 'overwriteSame' => * ) * b) Copy a file system file into storage @@ -106,7 +106,7 @@ abstract class FileBackendBase { * 'op' => 'store', * 'src' => , * 'dst' => , - * 'overwriteDest' => , + * 'overwrite' => , * 'overwriteSame' => * ) * c) Copy a file within storage @@ -114,7 +114,7 @@ abstract class FileBackendBase { * 'op' => 'copy', * 'src' => , * 'dst' => , - * 'overwriteDest' => , + * 'overwrite' => , * 'overwriteSame' => * ) * d) Move a file within storage @@ -122,7 +122,7 @@ abstract class FileBackendBase { * 'op' => 'move', * 'src' => , * 'dst' => , - * 'overwriteDest' => , + * 'overwrite' => , * 'overwriteSame' => * ) * e) Delete a file within storage @@ -139,7 +139,7 @@ abstract class FileBackendBase { * Boolean flags for operations (operation-specific): * 'ignoreMissingSource' : The operation will simply succeed and do * nothing if the source file does not exist. - * 'overwriteDest' : Any destination file will be overwritten. + * 'overwrite' : Any destination file will be overwritten. * 'overwriteSame' : An error will not be given if a file already * exists at the destination that has the same * contents as the new contents to be written there. @@ -612,7 +612,7 @@ abstract class FileBackend extends FileBackendBase { * $params include: * content : the raw file contents * dst : destination storage path - * overwriteDest : overwrite any file that exists at the destination + * overwrite : overwrite any file that exists at the destination * * @param $params Array * @return Status @@ -639,7 +639,7 @@ abstract class FileBackend extends FileBackendBase { * $params include: * src : source path on disk * dst : destination storage path - * overwriteDest : overwrite any file that exists at the destination + * overwrite : overwrite any file that exists at the destination * * @param $params Array * @return Status @@ -666,7 +666,7 @@ abstract class FileBackend extends FileBackendBase { * $params include: * src : source storage path * dst : destination storage path - * overwriteDest : overwrite any file that exists at the destination + * overwrite : overwrite any file that exists at the destination * * @param $params Array * @return Status @@ -711,7 +711,7 @@ abstract class FileBackend extends FileBackendBase { * $params include: * src : source storage path * dst : destination storage path - * overwriteDest : overwrite any file that exists at the destination + * overwrite : overwrite any file that exists at the destination * * @param $params Array * @return Status diff --git a/includes/filerepo/backend/FileOp.php b/includes/filerepo/backend/FileOp.php index 4a5e0c7154..86f2a942f0 100644 --- a/includes/filerepo/backend/FileOp.php +++ b/includes/filerepo/backend/FileOp.php @@ -262,7 +262,7 @@ abstract class FileOp { } $this->destSameAsSource = false; if ( $this->fileExists( $this->params['dst'], $predicates ) ) { - if ( $this->getParam( 'overwriteDest' ) ) { + if ( $this->getParam( 'overwrite' ) ) { return $status; // OK } elseif ( $this->getParam( 'overwriteSame' ) ) { $dhash = $this->fileSha1( $this->params['dst'], $predicates ); @@ -382,12 +382,12 @@ class FileOpScopedPHPTimeout { * Parameters similar to FileBackend::storeInternal(), which include: * src : source path on file system * dst : destination storage path - * overwriteDest : do nothing and pass if an identical file exists at destination + * overwrite : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ class StoreFileOp extends FileOp { protected function allowedParams() { - return array( 'src', 'dst', 'overwriteDest', 'overwriteSame' ); + return array( 'src', 'dst', 'overwrite', 'overwriteSame' ); } protected function doPrecheck( array &$predicates ) { @@ -442,12 +442,12 @@ class StoreFileOp extends FileOp { * Parameters similar to FileBackend::createInternal(), which include: * content : a string of raw file contents * dst : destination storage path - * overwriteDest : do nothing and pass if an identical file exists at destination + * overwrite : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ class CreateFileOp extends FileOp { protected function allowedParams() { - return array( 'content', 'dst', 'overwriteDest', 'overwriteSame' ); + return array( 'content', 'dst', 'overwrite', 'overwriteSame' ); } protected function doPrecheck( array &$predicates ) { @@ -491,12 +491,12 @@ class CreateFileOp extends FileOp { * Parameters similar to FileBackend::copyInternal(), which include: * src : source storage path * dst : destination storage path - * overwriteDest : do nothing and pass if an identical file exists at destination + * overwrite : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ class CopyFileOp extends FileOp { protected function allowedParams() { - return array( 'src', 'dst', 'overwriteDest', 'overwriteSame' ); + return array( 'src', 'dst', 'overwrite', 'overwriteSame' ); } protected function doPrecheck( array &$predicates ) { @@ -543,12 +543,12 @@ class CopyFileOp extends FileOp { * Parameters similar to FileBackend::moveInternal(), which include: * src : source storage path * dst : destination storage path - * overwriteDest : do nothing and pass if an identical file exists at destination + * overwrite : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ class MoveFileOp extends FileOp { protected function allowedParams() { - return array( 'src', 'dst', 'overwriteDest', 'overwriteSame' ); + return array( 'src', 'dst', 'overwrite', 'overwriteSame' ); } protected function doPrecheck( array &$predicates ) { diff --git a/includes/filerepo/backend/SwiftFileBackend.php b/includes/filerepo/backend/SwiftFileBackend.php index cba0d40243..a2d9a38e64 100644 --- a/includes/filerepo/backend/SwiftFileBackend.php +++ b/includes/filerepo/backend/SwiftFileBackend.php @@ -87,7 +87,7 @@ class SwiftFileBackend extends FileBackend { // (a) Check the destination container and object try { $dContObj = $this->getContainer( $dstCont ); - if ( empty( $params['overwriteDest'] ) ) { + if ( empty( $params['overwrite'] ) ) { $destObj = $dContObj->create_object( $dstRel ); // Check if the object already exists (fields populated) if ( $destObj->last_modified ) { @@ -145,7 +145,7 @@ class SwiftFileBackend extends FileBackend { // (a) Check the destination container and object try { $dContObj = $this->getContainer( $dstCont ); - if ( empty( $params['overwriteDest'] ) ) { + if ( empty( $params['overwrite'] ) ) { $destObj = $dContObj->create_object( $dstRel ); // Check if the object already exists (fields populated) if ( $destObj->last_modified ) { @@ -217,7 +217,7 @@ class SwiftFileBackend extends FileBackend { try { $sContObj = $this->getContainer( $srcCont ); $dContObj = $this->getContainer( $dstCont ); - if ( empty( $params['overwriteDest'] ) ) { + if ( empty( $params['overwrite'] ) ) { $destObj = $dContObj->create_object( $dstRel ); // Check if the object already exists (fields populated) if ( $destObj->last_modified ) { diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 67345a686e..fcac5b8349 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -811,7 +811,7 @@ abstract class File { // FileRepo::store(); getThumbPath() uses a different zone in some subclasses. $backend->prepare( array( 'dir' => dirname( $thumbPath ) ) ); $status = $backend->store( - array( 'src' => $tmpThumbPath, 'dst' => $thumbPath, 'overwriteDest' => 1 ), + array( 'src' => $tmpThumbPath, 'dst' => $thumbPath, 'overwrite' => 1 ), array( 'force' => 1, 'nonLocking' => 1, 'allowStale' => 1 ) ); if ( $status->isOK() ) { diff --git a/tests/phpunit/includes/filerepo/FileBackendTest.php b/tests/phpunit/includes/filerepo/FileBackendTest.php index 2c64687347..e6e5e4e23f 100644 --- a/tests/phpunit/includes/filerepo/FileBackendTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendTest.php @@ -110,7 +110,7 @@ class FileBackendTest extends MediaWikiTestCase { $toPath, // dest ); - $op['overwriteDest'] = true; + $op['overwrite'] = true; $cases[] = array( $op, // operation $tmpName, // source @@ -183,7 +183,7 @@ class FileBackendTest extends MediaWikiTestCase { $dest, // dest ); - $op['overwriteDest'] = true; + $op['overwrite'] = true; $cases[] = array( $op, // operation $source, // source @@ -258,7 +258,7 @@ class FileBackendTest extends MediaWikiTestCase { $dest, // dest ); - $op['overwriteDest'] = true; + $op['overwrite'] = true; $cases[] = array( $op, // operation $source, // source @@ -439,7 +439,7 @@ class FileBackendTest extends MediaWikiTestCase { strlen( $dummyText ) ); - $op['overwriteDest'] = true; + $op['overwrite'] = true; $cases[] = array( $op, // operation $source, // source @@ -792,27 +792,27 @@ class FileBackendTest extends MediaWikiTestCase { $this->backend->create( array( 'dst' => $fileC, 'content' => $fileCContents ) ); $status = $this->backend->doOperations( array( - array( 'op' => 'copy', 'src' => $fileA, 'dst' => $fileC, 'overwriteDest' => 1 ), + array( 'op' => 'copy', 'src' => $fileA, 'dst' => $fileC, 'overwrite' => 1 ), // Now: A:, B:, C:, D: (file:) array( 'op' => 'copy', 'src' => $fileC, 'dst' => $fileA, 'overwriteSame' => 1 ), // Now: A:, B:, C:, D: - array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileD, 'overwriteDest' => 1 ), + array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileD, 'overwrite' => 1 ), // Now: A:, B:, C:, D: array( 'op' => 'move', 'src' => $fileB, 'dst' => $fileC ), // Now: A:, B:, C:, D: array( 'op' => 'move', 'src' => $fileD, 'dst' => $fileA, 'overwriteSame' => 1 ), // Now: A:, B:, C:, D: - array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileA, 'overwriteDest' => 1 ), + array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileA, 'overwrite' => 1 ), // Now: A:, B:, C:, D: array( 'op' => 'copy', 'src' => $fileA, 'dst' => $fileC ), // Now: A:, B:, C:, D: array( 'op' => 'move', 'src' => $fileA, 'dst' => $fileC, 'overwriteSame' => 1 ), // Now: A:, B:, C:, D: - array( 'op' => 'copy', 'src' => $fileC, 'dst' => $fileC, 'overwriteDest' => 1 ), + array( 'op' => 'copy', 'src' => $fileC, 'dst' => $fileC, 'overwrite' => 1 ), // Does nothing array( 'op' => 'copy', 'src' => $fileC, 'dst' => $fileC, 'overwriteSame' => 1 ), // Does nothing - array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileC, 'overwriteDest' => 1 ), + array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileC, 'overwrite' => 1 ), // Does nothing array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileC, 'overwriteSame' => 1 ), // Does nothing -- 2.20.1