r72021 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72020‎ | r72021 | r72022 >
Date:11:12, 31 August 2010
Author:platonides
Status:ok
Tags:
Comment:
(Bug 20744) - Wiki forgets about an uploaded file
(Bug 24978) - "A file disappeared" thread on Commons:VP
Only save the LocalFile to memcache after the db entry has been commited.
Otherwise, when the transaction fails, the file apparently succeeded, but
after a week (memcached expiry) it disappears.
Fixes bug 20744 and bug 24978. Found by the Great Domas.

The correlation with db problems is probably just that in such case there are more transactions get rollbacked.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -807,12 +807,12 @@
808808 $props['timestamp'] = wfTimestamp( TS_MW );
809809 $this->setProps( $props );
810810
811 - // Delete thumbnails and refresh the metadata cache
 811+ # Delete thumbnails
812812 $this->purgeThumbnails();
813 - $this->saveToCache();
 813+ # The file is already on its final location, remove it from the squid cache
814814 SquidUpdate::purge( array( $this->getURL() ) );
815815
816 - // Fail now if the file isn't there
 816+ # Fail now if the file isn't there
817817 if ( !$this->fileExists ) {
818818 wfDebug( __METHOD__ . ": File " . $this->getPath() . " went missing!\n" );
819819 return false;
@@ -922,8 +922,9 @@
923923 $descTitle->invalidateCache();
924924 $descTitle->purgeSquid();
925925 } else {
926 - // New file; create the description page.
927 - // There's already a log entry, so don't make a second RC entry
 926+ # New file; create the description page.
 927+ # There's already a log entry, so don't make a second RC entry
 928+ # Squid and file cache for the description page are purged by doEdit.
928929 $article->doEdit( $pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC );
929930 }
930931
@@ -934,6 +935,12 @@
935936 # The most important thing is that files don't get lost, especially archives
936937 $dbw->commit();
937938
 939+ # Save to cache and purge the squid
 940+ # We shall not saveToCache before the commit since otherwise
 941+ # in case of a rollback there is an usable file from memcached
 942+ # which in fact doesn't really exist (bug 24978)
 943+ $this->saveToCache();
 944+
938945 # Invalidate cache for all pages using this file
939946 $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
940947 $update->doUpdate();
Index: trunk/phase3/RELEASE-NOTES
@@ -309,6 +309,7 @@
310310 * Disable multithreaded behaviour in recent ImageMagick, to avoid a deadlock
311311 when a resource limit such as $wgMaxShellMemory is hit.
312312 * (bug 24981) Allow extensions to access SpecialUpload variables again
 313+* (bug 20744) Wiki forgets about an uploaded file
313314
314315 === API changes in 1.17 ===
315316 * (bug 22738) Allow filtering by action type on query=logevent.

Status & tagging log