From: Aaron Schulz Date: Sat, 2 Apr 2011 16:49:47 +0000 (+0000) Subject: (bug 28348) Don't call wfTimestamp() twice really fast in recordUpload2() and expect... X-Git-Tag: 1.31.0-rc.0~31074 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=3b3d26ef44946d8d71c5d4c89c1c7b735c73b468;p=lhc%2Fweb%2Fwiklou.git (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). --- 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.