Add `actor` table and code to start using it
[lhc/web/wiklou.git] / includes / specials / pagers / DeletedContribsPager.php
index 43d7ad4..d642e66 100644 (file)
@@ -58,7 +58,12 @@ class DeletedContribsPager extends IndexPager {
        }
 
        function getQueryInfo() {
-               list( $index, $userCond ) = $this->getUserCond();
+               $userCond = [
+                       // ->getJoin() below takes care of any joins needed
+                       ActorMigration::newMigration()->getWhere(
+                               wfGetDB( DB_REPLICA ), 'ar_user', User::newFromName( $this->target, false ), false
+                       )['conds']
+               ];
                $conds = array_merge( $userCond, $this->getNamespaceCond() );
                $user = $this->getUser();
                // Paranoia: avoid brute force searches (T19792)
@@ -69,14 +74,18 @@ class DeletedContribsPager extends IndexPager {
                                ' != ' . Revision::SUPPRESSED_USER;
                }
 
+               $commentQuery = CommentStore::getStore()->getJoin( 'ar_comment' );
+               $actorQuery = ActorMigration::newMigration()->getJoin( 'ar_user' );
+
                return [
-                       'tables' => [ 'archive' ],
+                       'tables' => [ 'archive' ] + $commentQuery['tables'] + $actorQuery['tables'],
                        'fields' => [
-                               'ar_rev_id', 'ar_namespace', 'ar_title', 'ar_timestamp', 'ar_comment',
-                               'ar_minor_edit', 'ar_user', 'ar_user_text', 'ar_deleted'
-                       ],
+                               'ar_rev_id', 'ar_namespace', 'ar_title', 'ar_timestamp',
+                               'ar_minor_edit', 'ar_deleted'
+                       ] + $commentQuery['fields'] + $actorQuery['fields'],
                        'conds' => $conds,
-                       'options' => [ 'USE INDEX' => $index ]
+                       'options' => [],
+                       'join_conds' => $commentQuery['joins'] + $actorQuery['joins'],
                ];
        }
 
@@ -125,15 +134,6 @@ class DeletedContribsPager extends IndexPager {
                return new FakeResultWrapper( $result );
        }
 
-       function getUserCond() {
-               $condition = [];
-
-               $condition['ar_user_text'] = $this->target;
-               $index = 'ar_usertext_timestamp';
-
-               return [ $index, $condition ];
-       }
-
        function getIndexField() {
                return 'ar_timestamp';
        }
@@ -204,14 +204,14 @@ class DeletedContribsPager extends IndexPager {
                 * we're definitely dealing with revision data and we may proceed, if not, we'll leave it
                 * to extensions to subscribe to the hook to parse the row.
                 */
-               MediaWiki\suppressWarnings();
+               Wikimedia\suppressWarnings();
                try {
                        $rev = Revision::newFromArchiveRow( $row );
                        $validRevision = (bool)$rev->getId();
                } catch ( Exception $e ) {
                        $validRevision = false;
                }
-               MediaWiki\restoreWarnings();
+               Wikimedia\restoreWarnings();
 
                if ( $validRevision ) {
                        $attribs['data-mw-revid'] = $rev->getId();
@@ -253,9 +253,10 @@ class DeletedContribsPager extends IndexPager {
                $rev = new Revision( [
                        'title' => $page,
                        'id' => $row->ar_rev_id,
-                       'comment' => $row->ar_comment,
+                       'comment' => CommentStore::getStore()->getComment( 'ar_comment', $row )->text,
                        'user' => $row->ar_user,
                        'user_text' => $row->ar_user_text,
+                       'actor' => isset( $row->ar_actor ) ? $row->ar_actor : null,
                        'timestamp' => $row->ar_timestamp,
                        'minor_edit' => $row->ar_minor_edit,
                        'deleted' => $row->ar_deleted,