// SELECT FOR UPDATE only locks records not the gaps where there are none.
$cache = wfGetMainCache();
$key = $this->getCacheKey();
- if ( !$cache->lock( $key, 60 ) ) {
+ if ( !$cache->lock( $key, 5 ) ) {
throw new MWException( "Could not acquire lock for '{$this->getName()}.'" );
}
$dbw->onTransactionIdle( function () use ( $cache, $key ) {
return $this->getRepo()->newFatal( 'filereadonlyerror', $this->getName(),
$this->getRepo()->getName(), $this->getRepo()->getReadOnlyReason() );
}
+
+ /**
+ * Clean up any dangling locks
+ */
+ function __destruct() {
+ $this->unlock();
+ }
} // LocalFile class
# ------------------------------------------------------------------------------
$triplets = $this->getMoveTriplets();
$triplets = $this->removeNonexistentFiles( $triplets );
+ $destFile = wfLocalFile( $this->target );
$this->file->lock(); // begin
+ $destFile->lock(); // quickly fail if destination is not available
// Rename the file versions metadata in the DB.
// This implicitly locks the destination file, which avoids race conditions.
// If we moved the files from A -> C before DB updates, another process could
return $statusMove;
}
+ $destFile->unlock();
$this->file->unlock(); // done
// Everything went ok, remove the source files