+ list( $limit, $offset ) = $this->getRequest()->getLimitOffset();
+ if ( !$this->getConfig()->get( 'MiserMode' ) ) {
+ $maxResults = $this->getMaxResults();
+ // Can't display more than max results on a page
+ $limit = min( $limit, $maxResults );
+ // Can't skip over more than $maxResults
+ $offset = min( $offset, $maxResults );
+ // Can't let $offset + $limit > $maxResults
+ $limit = min( $limit, $maxResults - $offset );
+ }
+ return array( $limit, $offset );
+ }
+
+ /**
+ * Get max number of results we can return in miser mode.
+ *
+ * Most QueryPage subclasses use inefficient paging, so limit the max amount we return
+ * This matters for uncached query pages that might otherwise accept an offset of 3 million
+ *
+ * @since 1.27
+ * @return int
+ */
+ protected function getMaxResults() {
+ // Max of 10000, unless we store more than 5000 in query cache.
+ return max( $this->getConfig()->get( 'QueryCacheLimit' ), 10000 );