Allow limit and offset to be restricted in subclasses of QueryPage.php
authordaniel <daniel.kinzler@wikimedia.de>
Wed, 17 Jun 2015 15:26:03 +0000 (17:26 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Thu, 18 Jun 2015 19:51:10 +0000 (19:51 +0000)
Change-Id: Ib54b50619a0f412e53f92d48821221a243f19756

includes/WebRequest.php
includes/specialpage/QueryPage.php

index 05e229d..b9c9b86 100644 (file)
@@ -774,7 +774,7 @@ class WebRequest {
         *
         * @param int $deflimit Limit to use if no input and the user hasn't set the option.
         * @param string $optionname To specify an option other than rclimit to pull from.
-        * @return array First element is limit, second is offset
+        * @return int[] First element is limit, second is offset
         */
        public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) {
                global $wgUser;
index bd3b55b..69e1d8c 100644 (file)
@@ -470,6 +470,18 @@ abstract class QueryPage extends SpecialPage {
                return $this->cachedTimestamp;
        }
 
+       /**
+        * Returns limit and offset, as returned by $this->getRequest()->getLimitOffset().
+        * Subclasses may override this to further restrict or modify limit and offset.
+        *
+        * @since 1.26
+        *
+        * @return int[] list( $limit, $offset )
+        */
+       protected function getLimitOffset() {
+               return $this->getRequest()->getLimitOffset();
+       }
+
        /**
         * This is the actual workhorse. It does everything needed to make a
         * real, honest-to-gosh query page.
@@ -495,7 +507,7 @@ abstract class QueryPage extends SpecialPage {
                $out->setSyndicated( $this->isSyndicated() );
 
                if ( $this->limit == 0 && $this->offset == 0 ) {
-                       list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset();
+                       list( $this->limit, $this->offset ) = $this->getLimitOffset();
                }
 
                // @todo Use doQuery()