From 3b3d26ef44946d8d71c5d4c89c1c7b735c73b468 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 2 Apr 2011 16:49:47 +0000 Subject: [PATCH] (bug 28348) Don't call wfTimestamp() twice really fast in recordUpload2() and expect the values to be the same. Previously the file prop cache value for the upload timestamp could fall out of sync for a while due to this (like being off by one second). --- includes/filerepo/LocalFile.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index d495c00c05..9aa565968a 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -859,8 +859,9 @@ class LocalFile extends File { /** * Record a file upload in the upload log and the image table */ - function recordUpload2( $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null ) - { + function recordUpload2( + $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null + ) { if ( is_null( $user ) ) { global $wgUser; $user = $wgUser; @@ -873,10 +874,14 @@ class LocalFile extends File { $props = $this->repo->getFileProps( $this->getVirtualUrl() ); } + if ( $timestamp === false ) { + $timestamp = $dbw->timestamp(); + } + $props['description'] = $comment; $props['user'] = $user->getId(); $props['user_text'] = $user->getName(); - $props['timestamp'] = wfTimestamp( TS_MW ); + $props['timestamp'] = wfTimestamp( TS_MW, $timestamp ); // DB -> TS_MW $this->setProps( $props ); # Delete thumbnails @@ -893,10 +898,6 @@ class LocalFile extends File { $reupload = false; - if ( $timestamp === false ) { - $timestamp = $dbw->timestamp(); - } - # Test to see if the row exists using INSERT IGNORE # This avoids race conditions by locking the row until the commit, and also # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition. -- 2.20.1