Provide a RevisionRecord with the correct title after a move
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 6 Sep 2018 18:02:53 +0000 (14:02 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 6 Sep 2018 18:05:17 +0000 (14:05 -0400)
Currently we're creating the null revision for the move before actually
updating the page's title, so when it gets passed through
RevisionRenderer the output uses the old page's title in the <h1>.

To make that null revision have the correct title, let's try simply
updating the page table before creating it instead. The ordering
shouldn't matter since this all happens in an atomic section.

Bug: T203661
Change-Id: I9ebdcbc566b11dea3a9bdd402ea4418c4e51b096

includes/MovePage.php

index ec44b6e..2ad3158 100644 (file)
@@ -523,15 +523,6 @@ class MovePage {
 
                $newpage = WikiPage::factory( $nt );
 
-               # Save a null revision in the page's history notifying of the move
-               $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true, $user );
-               if ( !is_object( $nullRevision ) ) {
-                       throw new MWException( 'No valid null revision produced in ' . __METHOD__ );
-               }
-
-               $nullRevId = $nullRevision->insertOn( $dbw );
-               $logEntry->setAssociatedRevId( $nullRevId );
-
                # Change the name of the target page:
                $dbw->update( 'page',
                        /* SET */ [
@@ -542,6 +533,15 @@ class MovePage {
                        __METHOD__
                );
 
+               # Save a null revision in the page's history notifying of the move
+               $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true, $user );
+               if ( !is_object( $nullRevision ) ) {
+                       throw new MWException( 'No valid null revision produced in ' . __METHOD__ );
+               }
+
+               $nullRevId = $nullRevision->insertOn( $dbw );
+               $logEntry->setAssociatedRevId( $nullRevId );
+
                if ( !$redirectContent ) {
                        // Clean up the old title *before* reset article id - T47348
                        WikiPage::onArticleDelete( $this->oldTitle );