(bug 31179) Fixed problems with undeletion making bad page rows:
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 4 Oct 2011 21:31:31 +0000 (21:31 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 4 Oct 2011 21:31:31 +0000 (21:31 +0000)
* Moved up isCountable() call, since insertOn() sets the page ID, it safer to do this call first. It now uses master DB data, as it should for reads to write data. Furthermore, calling it after insertOn() was triggered loadPageData() on a slave, breaking the page ID cache just set in insertOn().
* Preemptively call loadPageData( 'fromdbmaster' ) as Article::doEdit() does (r98880) to avoid any lazy loading from the slave which can corrupt the page ID cache.

includes/specials/SpecialUndelete.php

index 6581a1c..85f3251 100644 (file)
@@ -399,6 +399,10 @@ class PageArchive {
 
                # Does this page already exist? We'll have to update it...
                $article = new Article( $this->title );
+               # Load latest data for the current page (bug 31179)
+               $article->loadPageData( 'fromdbmaster' );
+               $oldcountable = $article->isCountable();
+
                $options = 'FOR UPDATE'; // lock page
                $page = $dbw->selectRow( 'page',
                        array( 'page_id', 'page_latest' ),
@@ -532,7 +536,6 @@ class PageArchive {
                }
 
                $created = (bool)$newid;
-               $oldcountable = $article->isCountable();
 
                // Attach the latest revision to the page...
                $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId );