Add oldRev parameter to DiffRevisionTools hook
[lhc/web/wiklou.git] / includes / Pager.php
index 89930e2..6a10e88 100644 (file)
@@ -150,7 +150,8 @@ abstract class IndexPager extends ContextSource implements Pager {
                }
 
                $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' );
-               $this->mDb = wfGetDB( DB_SLAVE );
+               # Let the subclass set the DB here; otherwise use a slave DB for the current wiki
+               $this->mDb = $this->mDb ?: wfGetDB( DB_SLAVE );
 
                $index = $this->getIndexField(); // column to sort on
                $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
@@ -256,7 +257,7 @@ abstract class IndexPager extends ContextSource implements Pager {
         * @param $limit Int|String
         */
        function setLimit( $limit ) {
-               $limit = (int) $limit;
+               $limit = (int)$limit;
                // WebRequest::getLimitOffset() puts a cap of 5000, so do same here.
                if ( $limit > 5000 ) {
                        $limit = 5000;
@@ -266,6 +267,15 @@ abstract class IndexPager extends ContextSource implements Pager {
                }
        }
 
+       /**
+        * Get the current limit
+        *
+        * @return int
+        */
+       function getLimit() {
+               return $this->mLimit;
+       }
+
        /**
         * Set whether a row matching exactly the offset should be also included
         * in the result or not. By default this is not the case, but when the
@@ -649,8 +659,8 @@ abstract class IndexPager extends ContextSource implements Pager {
         * representing the result row $row. Rows will be concatenated and
         * returned by getBody()
         *
-        * @param $row Object: database row
-        * @return String
+        * @param array|stdClass $row Database row
+        * @return string
         */
        abstract function formatRow( $row );