Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/87010
Change subject: Make sure LocalFile::lock() works for brand new uploads
......................................................................
Make sure LocalFile::lock() works for brand new uploads
bug: 54763
Change-Id: I10f950939d34ff5917d168ef1d905c86e2cfc075
---
M includes/filerepo/file/LocalFile.php
1 file changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/10/87010/1
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index d6dc150..0041a98 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1764,9 +1764,19 @@
$this->lockedOwnTrx = true;
}
$this->locked++;
+ // Bug 54736: use simple lock to handle when the file
does not exist.
+ // SELECT FOR UPDATE only locks records not the gaps
where there are none.
+ $cache = wfGetMainCache();
+ $key = $this->getCacheKey();
+ if ( !$cache->lock( $key, 60 ) ) {
+ throw new MWException( "Could not acquire lock
for '{$this->getName()}.'" );
+ }
+ $dbw->onTransactionIdle( function() use ( $cache, $key
) {
+ $cache->delete( $key ); // release on commit
+ } );
}
- return $dbw->selectField( 'image', '1',
+ $exists = $dbw->selectField( 'image', '1',
array( 'img_name' => $this->getName() ), __METHOD__,
array( 'FOR UPDATE' ) );
}
--
To view, visit https://gerrit.wikimedia.org/r/87010
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I10f950939d34ff5917d168ef1d905c86e2cfc075
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits