r85199 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85198‎ | r85199 | r85200 >
Date:16:49, 2 April 2011
Author:aaron
Status:ok
Tags:
Comment:
(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).
Modified paths:
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -859,8 +859,9 @@
860860 /**
861861 * Record a file upload in the upload log and the image table
862862 */
863 - function recordUpload2( $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null )
864 - {
 863+ function recordUpload2(
 864+ $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null
 865+ ) {
865866 if ( is_null( $user ) ) {
866867 global $wgUser;
867868 $user = $wgUser;
@@ -873,10 +874,14 @@
874875 $props = $this->repo->getFileProps( $this->getVirtualUrl() );
875876 }
876877
 878+ if ( $timestamp === false ) {
 879+ $timestamp = $dbw->timestamp();
 880+ }
 881+
877882 $props['description'] = $comment;
878883 $props['user'] = $user->getId();
879884 $props['user_text'] = $user->getName();
880 - $props['timestamp'] = wfTimestamp( TS_MW );
 885+ $props['timestamp'] = wfTimestamp( TS_MW, $timestamp ); // DB -> TS_MW
881886 $this->setProps( $props );
882887
883888 # Delete thumbnails
@@ -893,10 +898,6 @@
894899
895900 $reupload = false;
896901
897 - if ( $timestamp === false ) {
898 - $timestamp = $dbw->timestamp();
899 - }
900 -
901902 # Test to see if the row exists using INSERT IGNORE
902903 # This avoids race conditions by locking the row until the commit, and also
903904 # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.

Follow-up revisions

RevisionCommit summaryAuthorDate
r85200MFT r85199demon17:14, 2 April 2011
r85202Added bug 28348 cleanup scriptaaron17:57, 2 April 2011
r85435MFT: r84431, r84464, r84543, r84553, r84573, r84574, r84577, r84729, r84765, ...demon14:00, 5 April 2011

Status & tagging log