diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2012-10-29 16:56:43 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2012-10-29 17:13:02 -0700 |
commit | 9fd48446a13dd3e23f360dad3838269ffa7f73a4 (patch) | |
tree | 342527e839132c8bb43f98fbb9c1d3a26b1b1538 /includes/filebackend/FileBackendStore.php | |
parent | bc65ee0829b6a5ef89221aa621695fc5e2d5c7f8 (diff) | |
download | mediawikicore-9fd48446a13dd3e23f360dad3838269ffa7f73a4.tar.gz mediawikicore-9fd48446a13dd3e23f360dad3838269ffa7f73a4.zip |
[FileBackend] Simplified code for handling "overwrite" parameter.
* Since doQuickOperations() implicitely sets "overwrite", and doOperations() handles it
via FileOp, there is no reason to also have each backend double checking this parameter
to handle it. The parameter is no implicit for all the *Internal() functions. This does
not affect callers. It does reduce the amount of HEAD requests since 404s are not cached.
Change-Id: I7d827e16bc55fe5c7b9aa51ec0c6b2f7c0bb629e
Diffstat (limited to 'includes/filebackend/FileBackendStore.php')
-rw-r--r-- | includes/filebackend/FileBackendStore.php | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 5f562d2d8cbb..dd0bec950b39 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -83,12 +83,12 @@ abstract class FileBackendStore extends FileBackend { /** * Create a file in the backend with the given contents. + * This will overwrite any file that exists at the destination. * Do not call this function from places outside FileBackend and FileOp. * * $params include: * - content : the raw file contents * - dst : destination storage path - * - overwrite : overwrite any file that exists at the destination * - disposition : Content-Disposition header value for the destination * - async : Status will be returned immediately if supported. * If the status is OK, then its value field will be @@ -106,9 +106,7 @@ abstract class FileBackendStore extends FileBackend { } else { $status = $this->doCreateInternal( $params ); $this->clearCache( array( $params['dst'] ) ); - if ( !empty( $params['overwrite'] ) ) { // file possibly mutated - $this->deleteFileCache( $params['dst'] ); // persistent cache - } + $this->deleteFileCache( $params['dst'] ); // persistent cache } wfProfileOut( __METHOD__ . '-' . $this->name ); wfProfileOut( __METHOD__ ); @@ -122,12 +120,12 @@ abstract class FileBackendStore extends FileBackend { /** * Store a file into the backend from a file on disk. + * This will overwrite any file that exists at the destination. * Do not call this function from places outside FileBackend and FileOp. * * $params include: * - src : source path on disk * - dst : destination storage path - * - overwrite : overwrite any file that exists at the destination * - disposition : Content-Disposition header value for the destination * - async : Status will be returned immediately if supported. * If the status is OK, then its value field will be @@ -145,9 +143,7 @@ abstract class FileBackendStore extends FileBackend { } else { $status = $this->doStoreInternal( $params ); $this->clearCache( array( $params['dst'] ) ); - if ( !empty( $params['overwrite'] ) ) { // file possibly mutated - $this->deleteFileCache( $params['dst'] ); // persistent cache - } + $this->deleteFileCache( $params['dst'] ); // persistent cache } wfProfileOut( __METHOD__ . '-' . $this->name ); wfProfileOut( __METHOD__ ); @@ -161,12 +157,12 @@ abstract class FileBackendStore extends FileBackend { /** * Copy a file from one storage path to another in the backend. + * This will overwrite any file that exists at the destination. * Do not call this function from places outside FileBackend and FileOp. * * $params include: * - src : source storage path * - dst : destination storage path - * - overwrite : overwrite any file that exists at the destination * - disposition : Content-Disposition header value for the destination * - async : Status will be returned immediately if supported. * If the status is OK, then its value field will be @@ -180,9 +176,7 @@ abstract class FileBackendStore extends FileBackend { wfProfileIn( __METHOD__ . '-' . $this->name ); $status = $this->doCopyInternal( $params ); $this->clearCache( array( $params['dst'] ) ); - if ( !empty( $params['overwrite'] ) ) { // file possibly mutated - $this->deleteFileCache( $params['dst'] ); // persistent cache - } + $this->deleteFileCache( $params['dst'] ); // persistent cache wfProfileOut( __METHOD__ . '-' . $this->name ); wfProfileOut( __METHOD__ ); return $status; @@ -225,12 +219,12 @@ abstract class FileBackendStore extends FileBackend { /** * Move a file from one storage path to another in the backend. + * This will overwrite any file that exists at the destination. * Do not call this function from places outside FileBackend and FileOp. * * $params include: * - src : source storage path * - dst : destination storage path - * - overwrite : overwrite any file that exists at the destination * - disposition : Content-Disposition header value for the destination * - async : Status will be returned immediately if supported. * If the status is OK, then its value field will be @@ -245,9 +239,7 @@ abstract class FileBackendStore extends FileBackend { $status = $this->doMoveInternal( $params ); $this->clearCache( array( $params['src'], $params['dst'] ) ); $this->deleteFileCache( $params['src'] ); // persistent cache - if ( !empty( $params['overwrite'] ) ) { // file possibly mutated - $this->deleteFileCache( $params['dst'] ); // persistent cache - } + $this->deleteFileCache( $params['dst'] ); // persistent cache wfProfileOut( __METHOD__ . '-' . $this->name ); wfProfileOut( __METHOD__ ); return $status; |