Rename DB_SLAVE constant to DB_REPLICA
[lhc/web/wiklou.git] / includes / specials / pagers / ContribsPager.php
index 201e4e8..bc0ebc2 100644 (file)
@@ -64,16 +64,17 @@ class ContribsPager extends ReverseChronologicalPager {
                $this->deletedOnly = !empty( $options['deletedOnly'] );
                $this->topOnly = !empty( $options['topOnly'] );
                $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 );
 
-               // Most of this code will use the 'contributions' group DB, which can map to slaves
+               // 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 slave since the lookup pattern is not all by user.
-               $this->mDbSecondary = wfGetDB( DB_SLAVE ); // any random slave
-               $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
+               // queries should use a regular replica DB since the lookup pattern is not all by user.
+               $this->mDbSecondary = wfGetDB( DB_SLAVE ); // any random replica DB
+               $this->mDb = wfGetDB( DB_REPLICA, 'contributions' );
        }
 
        function getDefaultQuery() {
@@ -223,6 +224,11 @@ class ContribsPager extends ReverseChronologicalPager {
                                        ]
                                ];
                        }
+                       // (T140537) Disallow looking too far in the past for 'newbies' queries. If the user requested
+                       // a timestamp offset far in the past such that there are no edits by users with user_ids in
+                       // the range, we would end up scanning all revisions from that offset until start of time.
+                       $condition[] = 'rev_timestamp > ' .
+                               $this->mDb->addQuotes( $this->mDb->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
                } else {
                        $uid = User::idFromName( $this->target );
                        if ( $uid ) {
@@ -246,6 +252,10 @@ class ContribsPager extends ReverseChronologicalPager {
                        $condition[] = 'rev_parent_id = 0';
                }
 
+               if ( $this->hideMinor ) {
+                       $condition[] = 'rev_minor_edit = 0';
+               }
+
                return [ $tables, $index, $condition, $join_conds ];
        }
 
@@ -366,8 +376,9 @@ class ContribsPager extends ReverseChronologicalPager {
                        # Mark current revisions
                        $topmarktext = '';
                        $user = $this->getUser();
-                       if ( $row->rev_id == $row->page_latest ) {
+                       if ( $row->rev_id === $row->page_latest ) {
                                $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
+                               $classes[] = 'mw-contributions-current';
                                # Add rollback link
                                if ( !$row->page_is_new && $page->quickUserCan( 'rollback', $user )
                                        && $page->quickUserCan( 'edit', $user )
@@ -473,6 +484,8 @@ class ContribsPager extends ReverseChronologicalPager {
                        );
                        $classes = array_merge( $classes, $newClasses );
 
+                       Hooks::run( 'SpecialContributions::formatRow::flags', [ $this->getContext(), $row, &$flags ] );
+
                        $templateParams = [
                                'del' => $del,
                                'timestamp' => $d,