ContribsPager: Disallow looking too far in the past for 'newbies' queries
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 18 Jul 2016 16:43:37 +0000 (18:43 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 18 Jul 2016 16:46:57 +0000 (18:46 +0200)
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.

This might end up generating funny queries with redundant conditions
on rev_timestamp, but that should not be a problem, and trying to
tweak paging logic would probably be more difficult than this.

Bug: T140537
Change-Id: I2ac9abee09529620588923bbafbcac07ebe466b2

includes/specials/pagers/ContribsPager.php

index fe0b4fe..f8eba9a 100644 (file)
@@ -224,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 ) {