r108471 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108470‎ | r108471 | r108472 >
Date:21:04, 9 January 2012
Author:aaron
Status:ok
Tags:
Comment:
* Fixed FileOp::attemptBatch() bug that had status->ok set wrong if 'force' option was used.
* Added missing prepare() call to File::maybeDoTransform().
* Improved documentation.
Modified paths:
  • /trunk/phase3/includes/filerepo/backend/FileOp.php (modified) (history)
  • /trunk/phase3/includes/filerepo/file/File.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/file/File.php
@@ -806,10 +806,11 @@
807807 $thumb = $this->handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $params );
808808 }
809809 } elseif ( $thumb->hasFile() && !$thumb->fileIsSource() ) {
810 - // Copy the thumbnail from the file system into storage
811 - // We don't use FileRepo::store() because of hacky suclasses
812 - // overriding File::getThumbPath() to use a different zone (e.g. 'temp').
813 - $status = $this->repo->getBackend()->store(
 810+ $backend = $this->repo->getBackend();
 811+ // Copy the thumbnail from the file system into storage. This avoids using
 812+ // FileRepo::store(); getThumbPath() uses a different zone in some subclasses.
 813+ $backend->prepare( array( 'dir' => dirname( $thumbPath ) ) );
 814+ $status = $backend->store(
814815 array( 'src' => $tmpThumbPath, 'dst' => $thumbPath ),
815816 array( 'force' => 1, 'nonLocking' => 1, 'allowStale' => 1 )
816817 );
Index: trunk/phase3/includes/filerepo/backend/FileOp.php
@@ -76,6 +76,13 @@
7777 * Attempt a series of file operations.
7878 * Callers are responsible for handling file locking.
7979 *
 80+ * $opts is an array of options, including:
 81+ * 'force' : Errors that would normally cause a rollback do not.
 82+ * The remaining operations are still attempted if any fail.
 83+ * 'allowStale' : Don't require the latest available data.
 84+ * This can increase performance for non-critical writes.
 85+ * This has no effect unless the 'force' flag is set.
 86+ *
8087 * @param $performOps Array List of FileOp operations
8188 * @param $opts Array Batch operation options
8289 * @return Status
@@ -129,6 +136,7 @@
130137 }
131138 }
132139
 140+ $wasOk = $status->isOK();
133141 // Finish each operation...
134142 foreach ( $performOps as $index => $fileOp ) {
135143 if ( $fileOp->failed() ) {
@@ -146,7 +154,7 @@
147155 }
148156
149157 // Make sure status is OK, despite any finish() fatals
150 - $status->setResult( true, $status->value );
 158+ $status->setResult( $wasOk, $status->value );
151159
152160 return $status;
153161 }

Status & tagging log