From 582fd02fb9ca88a8acf0336af03e04469a424b33 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 14 May 2014 09:43:02 -0700 Subject: [PATCH] Use FOR UPDATE in prior LocalFile timestamp check * This covers the case with a snapshotted transaction outside of lock()/unlock() Change-Id: I8639c2e51cb918f452dc1576681d6224fb4fb2c0 --- includes/filerepo/file/LocalFile.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index e8f70fca8d..a8fa8bd67b 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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 -- 2.20.1