Renamed 'overwriteDest' FileBackend operation parameter to just 'overwrite', which...
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 19 Jan 2012 02:24:49 +0000 (02:24 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 19 Jan 2012 02:24:49 +0000 (02:24 +0000)
includes/filerepo/FileRepo.php
includes/filerepo/backend/FSFileBackend.php
includes/filerepo/backend/FileBackend.php
includes/filerepo/backend/FileOp.php
includes/filerepo/backend/SwiftFileBackend.php
includes/filerepo/file/File.php
tests/phpunit/includes/filerepo/FileBackendTest.php

index 78109b6..7e92b4d 100644 (file)
@@ -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,
                        );
                }
index a01f846..dc81c48 100644 (file)
@@ -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();
index 9fc15b5..636b054 100644 (file)
@@ -98,7 +98,7 @@ abstract class FileBackendBase {
         *         'op'                  => 'create',
         *         'dst'                 => <storage path>,
         *         'content'             => <string of new file contents>,
-        *         'overwriteDest'       => <boolean>,
+        *         'overwrite'           => <boolean>,
         *         'overwriteSame'       => <boolean>
         *     )
         * b) Copy a file system file into storage
@@ -106,7 +106,7 @@ abstract class FileBackendBase {
         *         'op'                  => 'store',
         *         'src'                 => <file system path>,
         *         'dst'                 => <storage path>,
-        *         'overwriteDest'       => <boolean>,
+        *         'overwrite'           => <boolean>,
         *         'overwriteSame'       => <boolean>
         *     )
         * c) Copy a file within storage
@@ -114,7 +114,7 @@ abstract class FileBackendBase {
         *         'op'                  => 'copy',
         *         'src'                 => <storage path>,
         *         'dst'                 => <storage path>,
-        *         'overwriteDest'       => <boolean>,
+        *         'overwrite'           => <boolean>,
         *         'overwriteSame'       => <boolean>
         *     )
         * d) Move a file within storage
@@ -122,7 +122,7 @@ abstract class FileBackendBase {
         *         'op'                  => 'move',
         *         'src'                 => <storage path>,
         *         'dst'                 => <storage path>,
-        *         'overwriteDest'       => <boolean>,
+        *         'overwrite'           => <boolean>,
         *         'overwriteSame'       => <boolean>
         *     )
         * 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
index 4a5e0c7..86f2a94 100644 (file)
@@ -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 ) {
index cba0d40..a2d9a38 100644 (file)
@@ -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 ) {
index 67345a6..fcac5b8 100644 (file)
@@ -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() ) {
index 2c64687..e6e5e4e 100644 (file)
@@ -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:<A>, B:<B>, C:<A>, D:<D> (file:<orginal contents>)
                        array( 'op' => 'copy', 'src' => $fileC, 'dst' => $fileA, 'overwriteSame' => 1 ),
                        // Now: A:<A>, B:<B>, C:<A>, D:<D>
-                       array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileD, 'overwriteDest' => 1 ),
+                       array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileD, 'overwrite' => 1 ),
                        // Now: A:<A>, B:<B>, C:<empty>, D:<A>
                        array( 'op' => 'move', 'src' => $fileB, 'dst' => $fileC ),
                        // Now: A:<A>, B:<empty>, C:<B>, D:<A>
                        array( 'op' => 'move', 'src' => $fileD, 'dst' => $fileA, 'overwriteSame' => 1 ),
                        // Now: A:<A>, B:<empty>, C:<B>, D:<empty>
-                       array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileA, 'overwriteDest' => 1 ),
+                       array( 'op' => 'move', 'src' => $fileC, 'dst' => $fileA, 'overwrite' => 1 ),
                        // Now: A:<B>, B:<empty>, C:<empty>, D:<empty>
                        array( 'op' => 'copy', 'src' => $fileA, 'dst' => $fileC ),
                        // Now: A:<B>, B:<empty>, C:<B>, D:<empty>
                        array( 'op' => 'move', 'src' => $fileA, 'dst' => $fileC, 'overwriteSame' => 1 ),
                        // Now: A:<empty>, B:<empty>, C:<B>, D:<empty>
-                       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