r4914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r4913‎ | r4914 | r4915 >
Date:02:19, 23 August 2004
Author:vibber
Status:old
Tags:
Comment:
Start migrating wfCheckLimits to WebRequest::getLimitOffset()
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -452,20 +452,8 @@
453453
454454 # Yay, more global functions!
455455 function wfCheckLimits( $deflimit = 50, $optionname = 'rclimit' ) {
456 - global $wgUser, $wgRequest;
457 -
458 - $limit = $wgRequest->getInt( 'limit', 0 );
459 - if( $limit < 0 ) $limit = 0;
460 - if( ( $limit == 0 ) && ( $optionname != '' ) ) {
461 - $limit = (int)$wgUser->getOption( $optionname );
462 - }
463 - if( $limit <= 0 ) $limit = $deflimit;
464 - if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
465 -
466 - $offset = $wgRequest->getInt( 'offset', 0 );
467 - if( $offset < 0 ) $offset = 0;
468 -
469 - return array( $limit, $offset );
 456+ global $wgRequest;
 457+ return $wgRequest->getLimitOffset( $deflimit, $optionname );
470458 }
471459
472460 # Escapes the given text so that it may be output using addWikiText()
Index: trunk/phase3/includes/WebRequest.php
@@ -145,6 +145,22 @@
146146 return htmlspecialchars( $this->appendQuery( $query ) );
147147 }
148148
 149+ function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) {
 150+ global $wgUser;
 151+
 152+ $limit = $this->getInt( 'limit', 0 );
 153+ if( $limit < 0 ) $limit = 0;
 154+ if( ( $limit == 0 ) && ( $optionname != '' ) ) {
 155+ $limit = (int)$wgUser->getOption( $optionname );
 156+ }
 157+ if( $limit <= 0 ) $limit = $deflimit;
 158+ if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
 159+
 160+ $offset = $this->getInt( 'offset', 0 );
 161+ if( $offset < 0 ) $offset = 0;
 162+
 163+ return array( $limit, $offset );
 164+ }
149165 }
150166
151167 ?>

Status & tagging log