Fix regression causing incorrect image data to be stored in the oldimage table.
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 4 May 2007 19:39:19 +0000 (19:39 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 4 May 2007 19:39:19 +0000 (19:39 +0000)
The call to upgradeRow() in purgeMetadataCache(), indirectly called during upload, caused data for the new file to be written into the 'image' table in the database before migration from 'image' to 'oldimage'. Thus data for the new file was recorded as belonging to the old file.
Have replaced this call with a call to loadFromFile(), so the new data goes only into cache
at this time, and won't get written to the database until after.
The 'purge' action in ImagePage now explicitly calls the upgradeRow() function in addition to cache purging... is it needed elsewhere?
This whole mess still stinks of race  conditions, though. Sigh.

includes/Image.php
includes/ImagePage.php

index 274661a..a898f9b 100644 (file)
@@ -1052,7 +1052,7 @@ class Image
         */
        function purgeMetadataCache() {
                clearstatcache();
-               $this->upgradeRow();
+               $this->loadFromFile();
                $this->saveToCache();
        }
 
index 4cf8730..a9f91ae 100644 (file)
@@ -698,6 +698,7 @@ END
                        wfDebug( "ImagePage::doPurge purging " . $this->img->getName() . "\n" );
                        $update = new HTMLCacheUpdate( $this->mTitle, 'imagelinks' );
                        $update->doUpdate();
+                       $this->img->upgradeRow();
                        $this->img->purgeCache();
                } else {
                        wfDebug( "ImagePage::doPurge no image\n" );