Merge "Remove unused WikiPage::getLastNAuthors() method"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 4 Dec 2015 19:20:33 +0000 (19:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 4 Dec 2015 19:20:33 +0000 (19:20 +0000)
1  2 
includes/page/WikiPage.php

@@@ -1027,55 -1027,6 +1027,6 @@@ class WikiPage implements Page, IDBAcce
                return new UserArrayFromResult( $res );
        }
  
-       /**
-        * Get the last N authors
-        * @param int $num Number of revisions to get
-        * @param int|string $revLatest The latest rev_id, selected from the master (optional)
-        * @return array Array of authors, duplicates not removed
-        */
-       public function getLastNAuthors( $num, $revLatest = 0 ) {
-               // First try the slave
-               // If that doesn't have the latest revision, try the master
-               $continue = 2;
-               $db = wfGetDB( DB_SLAVE );
-               do {
-                       $res = $db->select( array( 'page', 'revision' ),
-                               array( 'rev_id', 'rev_user_text' ),
-                               array(
-                                       'page_namespace' => $this->mTitle->getNamespace(),
-                                       'page_title' => $this->mTitle->getDBkey(),
-                                       'rev_page = page_id'
-                               ), __METHOD__,
-                               array(
-                                       'ORDER BY' => 'rev_timestamp DESC',
-                                       'LIMIT' => $num
-                               )
-                       );
-                       if ( !$res ) {
-                               return array();
-                       }
-                       $row = $db->fetchObject( $res );
-                       if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
-                               $db = wfGetDB( DB_MASTER );
-                               $continue--;
-                       } else {
-                               $continue = 0;
-                       }
-               } while ( $continue );
-               $authors = array( $row->rev_user_text );
-               foreach ( $res as $row ) {
-                       $authors[] = $row->rev_user_text;
-               }
-               return $authors;
-       }
        /**
         * Should the parser cache be used?
         *
  
                $title = $this->mTitle;
                wfGetDB( DB_MASTER )->onTransactionIdle( function() use ( $title ) {
 -                      global $wgUseSquid;
                        // Invalidate the cache in auto-commit mode
                        $title->invalidateCache();
 -                      if ( $wgUseSquid ) {
 -                              // Send purge now that page_touched update was committed above
 -                              $update = new SquidUpdate( $title->getSquidURLs() );
 -                              $update->doUpdate();
 -                      }
                } );
  
 +              // Send purge after above page_touched update was committed
 +              DeferredUpdates::addUpdate(
 +                      new SquidUpdate( $title->getSquidURLs() ),
 +                      DeferredUpdates::PRESEND
 +              );
 +
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                        // @todo move this logic to MessageCache
                        if ( $this->exists() ) {
                $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' );
                $bot = $flags & EDIT_FORCE_BOT;
  
 +              $old_revision = $this->getRevision(); // current revision
                $old_content = $this->getContent( Revision::RAW ); // current revision's content
  
                $oldsize = $old_content ? $old_content->getSize() : 0;
                                $user,
                                array(
                                        'changed' => $changed,
 -                                      'oldcountable' => $oldcountable
 +                                      'oldcountable' => $oldcountable,
 +                                      'oldrevision' => $old_revision
                                )
                        );
  
                        $this->mTimestamp = $now;
  
                        // Update links, etc.
 -                      $this->doEditUpdates( $revision, $user, array( 'created' => true ) );
 +                      $this->doEditUpdates(
 +                              $revision,
 +                              $user,
 +                              array( 'created' => true, 'oldrevision' => $old_revision )
 +                      );
  
                        $hook_args = array( &$this, &$user, $content, $summary,
                                                                $flags & EDIT_MINOR, null, null, &$flags, $revision );
         * - changed: boolean, whether the revision changed the content (default true)
         * - created: boolean, whether the revision created the page (default false)
         * - moved: boolean, whether the page was moved (default false)
 +       * - restored: boolean, whether the page was undeleted (default false)
 +       * - oldrevision: Revision object for the pre-update revision (default null)
         * - oldcountable: boolean, null, or string 'no-change' (default null):
         *   - boolean: whether the page was counted as an article before that
         *     revision, only used in changed is true and created is false
         *   - 'no-change': don't update the article count, ever
         */
        public function doEditUpdates( Revision $revision, User $user, array $options = array() ) {
 +              global $wgRCWatchCategoryMembership;
 +
                $options += array(
                        'changed' => true,
                        'created' => false,
                        'moved' => false,
 +                      'restored' => false,
 +                      'oldrevision' => null,
                        'oldcountable' => null
                );
                $content = $revision->getContent();
                if ( $content ) {
                        $recursive = $options['changed']; // bug 50785
                        $updates = $content->getSecondaryDataUpdates(
 -                              $this->getTitle(), null, $recursive, $editInfo->output );
 +                              $this->getTitle(), null, $recursive, $editInfo->output
 +                      );
                        foreach ( $updates as $update ) {
                                if ( $update instanceof LinksUpdate ) {
                                        $update->setRevision( $revision );
                                }
                                DeferredUpdates::addUpdate( $update );
                        }
 +                      if ( $wgRCWatchCategoryMembership
 +                              && ( $options['changed'] || $options['created'] )
 +                              && !$options['restored']
 +                      ) {
 +                              // Note: jobs are pushed after deferred updates, so the job should be able to see
 +                              // the recent change entry (also done via deferred updates) and carry over any
 +                              // bot/deletion/IP flags, ect.
 +                              JobQueueGroup::singleton()->lazyPush( new CategoryMembershipChangeJob(
 +                                      $this->getTitle(),
 +                                      array(
 +                                              'pageId' => $this->getId(),
 +                                              'revTimestamp' => $revision->getTimestamp()
 +                                      )
 +                              ) );
 +                      }
                }
  
                Hooks::run( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) );