From 35c74af604ec69beb06e25ed2de7098ee5884993 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 23 Aug 2004 02:19:02 +0000 Subject: [PATCH] Start migrating wfCheckLimits to WebRequest::getLimitOffset() --- includes/GlobalFunctions.php | 16 ++-------------- includes/WebRequest.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 606b98fd8b..a54497188a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -452,20 +452,8 @@ function wfClientAcceptsGzip() { # Yay, more global functions! function wfCheckLimits( $deflimit = 50, $optionname = 'rclimit' ) { - global $wgUser, $wgRequest; - - $limit = $wgRequest->getInt( 'limit', 0 ); - if( $limit < 0 ) $limit = 0; - if( ( $limit == 0 ) && ( $optionname != '' ) ) { - $limit = (int)$wgUser->getOption( $optionname ); - } - if( $limit <= 0 ) $limit = $deflimit; - if( $limit > 5000 ) $limit = 5000; # We have *some* limits... - - $offset = $wgRequest->getInt( 'offset', 0 ); - if( $offset < 0 ) $offset = 0; - - return array( $limit, $offset ); + global $wgRequest; + return $wgRequest->getLimitOffset( $deflimit, $optionname ); } # Escapes the given text so that it may be output using addWikiText() diff --git a/includes/WebRequest.php b/includes/WebRequest.php index a069ee7541..841ce29f0f 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -145,6 +145,22 @@ class WebRequest { return htmlspecialchars( $this->appendQuery( $query ) ); } + function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) { + global $wgUser; + + $limit = $this->getInt( 'limit', 0 ); + if( $limit < 0 ) $limit = 0; + if( ( $limit == 0 ) && ( $optionname != '' ) ) { + $limit = (int)$wgUser->getOption( $optionname ); + } + if( $limit <= 0 ) $limit = $deflimit; + if( $limit > 5000 ) $limit = 5000; # We have *some* limits... + + $offset = $this->getInt( 'offset', 0 ); + if( $offset < 0 ) $offset = 0; + + return array( $limit, $offset ); + } } ?> -- 2.20.1