(Bug 41617) Fix undelete.
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 1 Nov 2012 11:12:11 +0000 (12:12 +0100)
committerdaniel <daniel.kinzler@wikimedia.de>
Thu, 1 Nov 2012 11:12:11 +0000 (12:12 +0100)
Undeletion was broken twice:

1) originally, it failed silently, restoring revision entries with
the wrong number in rev_page.

2) I789e45bd restores an overly zealous sanity check, causing
undeletion to fail with a fatal error.

This change fixes both issues.

Change-Id: I796fe54e81773f7982ae9bc15ba30f2a2ee3f174

includes/Revision.php
includes/specials/SpecialUndelete.php

index 431be69..1ab44bf 100644 (file)
@@ -606,8 +606,9 @@ class Revision implements IDBAccessObject {
                                        // if the page ID wasn't known, set it now
                                        $this->mPage = $this->mTitle->getArticleID();
                                } elseif ( $this->mTitle->getArticleID() !== $this->mPage ) {
-                                       // got different page IDs, something is wrong.
-                                       throw new MWException( "Page ID " . $this->mPage . " mismatches the ID "
+                                       // Got different page IDs. This may be legit (e.g. during undeletion),
+                                       // but it seems worth mentioning it in the log.
+                                       wfDebug( "Page ID " . $this->mPage . " mismatches the ID "
                                                        . $this->mTitle->getArticleID() . " provided by the Title object." );
                                }
                        }
index 4c38a78..c0420e5 100644 (file)
@@ -575,6 +575,9 @@ class PageArchive {
                                        return Status::newFatal( "undeleterevdel" );
                                }
                        }
+
+                       $newid  = false;
+                       $pageId = $article->getId();
                }
 
                $revision = null;
@@ -593,6 +596,7 @@ class PageArchive {
                        // unless we are specifically removing all restrictions...
                        $revision = Revision::newFromArchiveRow( $row,
                                array(
+                                       'page' => $pageId,
                                        'title' => $this->title,
                                        'deleted' => $unsuppress ? 0 : $row->ar_deleted
                                ) );