From: Aaron Schulz Date: Tue, 13 May 2014 22:03:32 +0000 (-0700) Subject: Made LocalFile avoid duplicate (name,timestamp) pairs X-Git-Tag: 1.31.0-rc.0~15723^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=605329976fcad085ff954376297cfb20310d3c4d;p=lhc%2Fweb%2Fwiklou.git Made LocalFile avoid duplicate (name,timestamp) pairs * Various bits of code seem to assume uniqueness already bug: 65264 Change-Id: Ib00fdbe87a79296c640cd69d74928236ce7a4aee --- diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 73ab04d49a..e8f70fca8d 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1249,7 +1249,17 @@ class LocalFile extends File { } if ( $timestamp === false ) { - $timestamp = $dbw->timestamp(); + $ltimestamp = $dbw->selectField( 'image', 'img_timestamp', + array( 'img_name' => $this->getName() ), __METHOD__ ); + $ltime = $ltimestamp ? wfTimestamp( TS_UNIX, $ltimestamp ) : false; + $ctime = time(); + // Avoid a timestamp that is not newer than the last version + if ( $ctime > $ltime ) { + $timestamp = $dbw->timestamp( $ctime ); + } else { + sleep( 1 ); // fast enough uploads will go in to the future otherwise + $timestamp = $dbw->timestamp( $ltime + 1 ); + } } $props['description'] = $comment;