Use FOR UPDATE in prior LocalFile timestamp check
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 14 May 2014 16:43:02 +0000 (09:43 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 14 May 2014 16:43:02 +0000 (09:43 -0700)
* This covers the case with a snapshotted transaction outside of lock()/unlock()

Change-Id: I8639c2e51cb918f452dc1576681d6224fb4fb2c0

includes/filerepo/file/LocalFile.php

index e8f70fc..a8fa8bd 100644 (file)
@@ -1249,8 +1249,9 @@ class LocalFile extends File {
                }
 
                if ( $timestamp === false ) {
+                       // Use FOR UPDATE in case lock()/unlock() did not start the transaction
                        $ltimestamp = $dbw->selectField( 'image', 'img_timestamp',
-                               array( 'img_name' => $this->getName() ), __METHOD__ );
+                               array( 'img_name' => $this->getName() ), __METHOD__, array( 'FOR UPDATE' ) );
                        $ltime = $ltimestamp ? wfTimestamp( TS_UNIX, $ltimestamp ) : false;
                        $ctime = time();
                        // Avoid a timestamp that is not newer than the last version