Merge "Show total number of autoblocks on top of Special:AutoblockList"
[lhc/web/wiklou.git] / includes / specials / pagers / ContribsPager.php
index 5126bad..e690a3f 100644 (file)
@@ -26,8 +26,9 @@
 use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\ResultWrapper;
 use Wikimedia\Rdbms\FakeResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
 
-class ContribsPager extends ReverseChronologicalPager {
+class ContribsPager extends RangeChronologicalPager {
 
        public $mDefaultDirection = IndexPager::DIR_DESCENDING;
        public $messages;
@@ -44,6 +45,11 @@ class ContribsPager extends ReverseChronologicalPager {
         */
        protected $mParentLens;
 
+       /**
+        * @var TemplateParser
+        */
+       protected $templateParser;
+
        function __construct( IContextSource $context, array $options ) {
                parent::__construct( $context );
 
@@ -70,15 +76,23 @@ class ContribsPager extends ReverseChronologicalPager {
                $this->newOnly = !empty( $options['newOnly'] );
                $this->hideMinor = !empty( $options['hideMinor'] );
 
-               $year = isset( $options['year'] ) ? $options['year'] : false;
-               $month = isset( $options['month'] ) ? $options['month'] : false;
-               $this->getDateCond( $year, $month );
+               // Date filtering: use timestamp if available
+               $startTimestamp = '';
+               $endTimestamp = '';
+               if ( $options['start'] ) {
+                       $startTimestamp = $options['start'] . ' 00:00:00';
+               }
+               if ( $options['end'] ) {
+                       $endTimestamp = $options['end'] . ' 23:59:59';
+               }
+               $this->getDateRangeCond( $startTimestamp, $endTimestamp );
 
                // Most of this code will use the 'contributions' group DB, which can map to replica DBs
                // with extra user based indexes or partioning by user. The additional metadata
                // queries should use a regular replica DB since the lookup pattern is not all by user.
                $this->mDbSecondary = wfGetDB( DB_REPLICA ); // any random replica DB
                $this->mDb = wfGetDB( DB_REPLICA, 'contributions' );
+               $this->templateParser = new TemplateParser();
        }
 
        function getDefaultQuery() {
@@ -227,10 +241,8 @@ class ContribsPager extends ReverseChronologicalPager {
                                        'LEFT JOIN', [
                                                'ug_user = rev_user',
                                                'ug_group' => $groupsWithBotPermission,
-                                               $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
-                                                       '1' :
-                                                       'ug_expiry IS NULL OR ug_expiry >= ' .
-                                                               $this->mDb->addQuotes( $this->mDb->timestamp() )
+                                               'ug_expiry IS NULL OR ug_expiry >= ' .
+                                                       $this->mDb->addQuotes( $this->mDb->timestamp() )
                                        ]
                                ];
                        }
@@ -460,14 +472,13 @@ class ContribsPager extends ReverseChronologicalPager {
                        }
 
                        # Show user names for /newbies as there may be different users.
-                       # Note that we already excluded rows with hidden user names.
-                       if ( $this->contribs == 'newbie' ) {
+                       # Note that only unprivileged users have rows with hidden user names excluded.
+                       $userlink = '';
+                       if ( $this->contribs == 'newbie' && !$rev->isDeleted( Revision::DELETED_USER ) ) {
                                $userlink = ' . . ' . $lang->getDirMark()
                                        . Linker::userLink( $rev->getUser(), $rev->getUserText() );
                                $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
-                                               Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
-                       } else {
-                               $userlink = '';
+                                       Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
                        }
 
                        $flags = [];
@@ -517,8 +528,7 @@ class ContribsPager extends ReverseChronologicalPager {
                                        $this->msg( 'rev-deleted-user-contribs' )->escaped();
                        }
 
-                       $templateParser = new TemplateParser();
-                       $ret = $templateParser->processTemplate(
+                       $ret = $this->templateParser->processTemplate(
                                'SpecialContributionsLine',
                                $templateParams
                        );