Merge "Use regular slaves for user contribs parent revision queries"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 30 Jan 2014 19:02:27 +0000 (19:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 30 Jan 2014 19:02:27 +0000 (19:02 +0000)
1  2 
includes/specials/SpecialContributions.php

@@@ -27,7 -27,7 +27,7 @@@
   * @ingroup SpecialPage
   */
  
 -class SpecialContributions extends SpecialPage {
 +class SpecialContributions extends IncludableSpecialPage {
        protected $opts;
  
        public function __construct() {
@@@ -63,9 -63,8 +63,9 @@@
                $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
  
                if ( !strlen( $target ) ) {
 -                      $out->addHTML( $this->getForm() );
 -
 +                      if ( !$this->including() ) {
 +                              $out->addHTML( $this->getForm() );
 +                      }
                        return;
                }
  
                $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $target ) );
  
                if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id, $userObj, $this ) ) ) {
 -                      $out->addHTML( $this->getForm() );
 -
 +                      if ( !$this->including() ) {
 +                              $out->addHTML( $this->getForm() );
 +                      }
                        $pager = new ContribsPager( $this->getContext(), array(
                                'target' => $target,
                                'contribs' => $this->opts['contribs'],
                        }
  
                        if ( $message ) {
 -                              if ( !$this->msg( $message, $target )->isDisabled() ) {
 -                                      $out->wrapWikiMsg(
 -                                              "<div class='mw-contributions-footer'>\n$1\n</div>",
 -                                              array( $message, $target ) );
 +                              if ( !$this->including() ) {
 +                                      if ( !$this->msg( $message, $target )->isDisabled() ) {
 +                                              $out->wrapWikiMsg(
 +                                                      "<div class='mw-contributions-footer'>\n$1\n</div>",
 +                                                      array( $message, $target ) );
 +                                      }
                                }
                        }
                }
@@@ -605,6 -601,9 +605,9 @@@ class ContribsPager extends ReverseChro
        public $mDb;
        public $preventClickjacking = false;
  
+       /** @var DatabaseBase */
+       public $mDbSecondary;
        /**
         * @var array
         */
                $month = isset( $options['month'] ) ? $options['month'] : false;
                $this->getDateCond( $year, $month );
  
+               // Most of this code will use the 'contributions' group DB, which can map to slaves
+               // with extra user based indexes or partioning by user. The additional metadata
+               // queries should use a regular slave since the lookup pattern is not all by user.
+               $this->mDbSecondary = wfGetDB( DB_SLAVE ); // any random slave
                $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
        }
  
                                $batch->add( $row->page_namespace, $row->page_title );
                        }
                }
-               $this->mParentLens = Revision::getParentLengths( $this->getDatabase(), $revIds );
+               $this->mParentLens = Revision::getParentLengths( $this->mDbSecondary, $revIds );
                $batch->execute();
                $this->mResult->seek( 0 );
        }