jenkins-bot has submitted this change and it was merged.

Change subject: Make sure LocalFile::lock() works for brand new uploads
......................................................................


Make sure LocalFile::lock() works for brand new uploads

bug: 54736
Change-Id: I10f950939d34ff5917d168ef1d905c86e2cfc075
---
M includes/filerepo/file/LocalFile.php
1 file changed, 10 insertions(+), 0 deletions(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/filerepo/file/LocalFile.php 
b/includes/filerepo/file/LocalFile.php
index d6dc150..9653db9 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1764,6 +1764,16 @@
                                $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',

-- 
To view, visit https://gerrit.wikimedia.org/r/87010
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I10f950939d34ff5917d168ef1d905c86e2cfc075
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to