Merge "Make various MWCallableUpdate usages rollback-safe"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 16 Aug 2016 01:01:53 +0000 (01:01 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 16 Aug 2016 01:01:53 +0000 (01:01 +0000)
1  2 
includes/page/WikiPage.php

@@@ -90,14 -90,6 +90,14 @@@ class WikiPage implements Page, IDBAcce
                $this->mTitle = $title;
        }
  
 +      /**
 +       * Makes sure that the mTitle object is cloned
 +       * to the newly cloned WikiPage.
 +       */
 +      public function __clone() {
 +              $this->mTitle = clone $this->mTitle;
 +      }
 +
        /**
         * Create a WikiPage object of the appropriate class for the given title.
         *
                // Update the DB post-send if the page has not cached since now
                $that = $this;
                $latest = $this->getLatest();
-               DeferredUpdates::addCallableUpdate( function() use ( $that, $retval, $latest ) {
-                       $that->insertRedirectEntry( $retval, $latest );
-               } );
+               DeferredUpdates::addCallableUpdate(
+                       function () use ( $that, $retval, $latest ) {
+                               $that->insertRedirectEntry( $retval, $latest );
+                       },
+                       DeferredUpdates::POSTSEND,
+                       wfGetDB( DB_MASTER )
+               );
  
                return $retval;
        }
         * @param bool          $forceParse Force reindexing, regardless of cache settings
         * @return bool|ParserOutput ParserOutput or false if the revision was not found
         */
 -      public function getParserOutput( ParserOptions $parserOptions, $oldid = null,
 -                                       $forceParse = false ) {
 -
 +      public function getParserOutput(
 +              ParserOptions $parserOptions, $oldid = null, $forceParse = false
 +      ) {
                $useParserCache =
                        ( !$forceParse ) && $this->shouldCheckParserCache( $parserOptions, $oldid );
                wfDebug( __METHOD__ .
                // Save this so we can pass it to the ArticleDeleteComplete hook.
                $archivedRevisionCount = $dbw->affectedRows();
  
 +              // Clone the title and wikiPage, so we have the information we need when
 +              // we log and run the ArticleDeleteComplete hook.
 +              $logTitle = clone $this->mTitle;
 +              $wikiPageBeforeDelete = clone $this;
 +
                // Now that it's safely backed up, delete it
                $dbw->delete( 'page', [ 'page_id' => $id ], __METHOD__ );
  
                        $dbw->delete( 'revision', [ 'rev_page' => $id ], __METHOD__ );
                }
  
 -              // Clone the title, so we have the information we need when we log
 -              $logTitle = clone $this->mTitle;
 -
                // Log the deletion, if the page was suppressed, put it in the suppression log instead
                $logtype = $suppress ? 'suppress' : 'delete';
  
  
                $this->doDeleteUpdates( $id, $content );
  
 -              Hooks::run( 'ArticleDeleteComplete',
 -                      [ &$this, &$user, $reason, $id, $content, $logEntry, $archivedRevisionCount ] );
 +              Hooks::run( 'ArticleDeleteComplete', [
 +                      &$wikiPageBeforeDelete,
 +                      &$user,
 +                      $reason,
 +                      $id,
 +                      $content,
 +                      $logEntry,
 +                      $archivedRevisionCount
 +              ] );
                $status->value = $logid;
  
                // Show log excerpt on 404 pages rather than just a link