From 230c2ccab7d018651d9aab1633d84db181cdc35a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 9 Jan 2012 21:04:48 +0000 Subject: [PATCH] * Fixed FileOp::attemptBatch() bug that had status->ok set wrong if 'force' option was used. * Added missing prepare() call to File::maybeDoTransform(). * Improved documentation. --- includes/filerepo/backend/FileOp.php | 10 +++++++++- includes/filerepo/file/File.php | 9 +++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/includes/filerepo/backend/FileOp.php b/includes/filerepo/backend/FileOp.php index 4f6e226fd8..11fe865b56 100644 --- a/includes/filerepo/backend/FileOp.php +++ b/includes/filerepo/backend/FileOp.php @@ -76,6 +76,13 @@ abstract class FileOp { * Attempt a series of file operations. * Callers are responsible for handling file locking. * + * $opts is an array of options, including: + * 'force' : Errors that would normally cause a rollback do not. + * The remaining operations are still attempted if any fail. + * 'allowStale' : Don't require the latest available data. + * This can increase performance for non-critical writes. + * This has no effect unless the 'force' flag is set. + * * @param $performOps Array List of FileOp operations * @param $opts Array Batch operation options * @return Status @@ -129,6 +136,7 @@ abstract class FileOp { } } + $wasOk = $status->isOK(); // Finish each operation... foreach ( $performOps as $index => $fileOp ) { if ( $fileOp->failed() ) { @@ -146,7 +154,7 @@ abstract class FileOp { } // Make sure status is OK, despite any finish() fatals - $status->setResult( true, $status->value ); + $status->setResult( $wasOk, $status->value ); return $status; } diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index b5fe48168a..2554af5009 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -806,10 +806,11 @@ abstract class File { $thumb = $this->handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $params ); } } elseif ( $thumb->hasFile() && !$thumb->fileIsSource() ) { - // Copy the thumbnail from the file system into storage - // We don't use FileRepo::store() because of hacky suclasses - // overriding File::getThumbPath() to use a different zone (e.g. 'temp'). - $status = $this->repo->getBackend()->store( + $backend = $this->repo->getBackend(); + // Copy the thumbnail from the file system into storage. This avoids using + // FileRepo::store(); getThumbPath() uses a different zone in some subclasses. + $backend->prepare( array( 'dir' => dirname( $thumbPath ) ) ); + $status = $backend->store( array( 'src' => $tmpThumbPath, 'dst' => $thumbPath ), array( 'force' => 1, 'nonLocking' => 1, 'allowStale' => 1 ) ); -- 2.20.1