Merge "Use "elseif" instead of "else if" in PHP"
[lhc/web/wiklou.git] / includes / WebRequest.php
index b42564c..01366f4 100644 (file)
@@ -3,7 +3,7 @@
  * Deal with importing all those nasty globals and things
  *
  * Copyright © 2003 Brion Vibber <brion@pobox.com>
- * http://www.mediawiki.org/
+ * https://www.mediawiki.org/
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -795,12 +795,11 @@ class WebRequest {
         * defaults if not given. The limit must be positive and is capped at 5000.
         * Offset must be positive but is not capped.
         *
-        * @param int $deflimit limit to use if no input and the user hasn't set the option.
+        * @param $deflimit Integer: 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.
-        * @param int $hardlimit the maximum upper limit to allow, usually 5000
         * @return array first element is limit, second is offset
         */
-       public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit', $hardlimit = 5000 ) {
+       public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) {
                global $wgUser;
 
                $limit = $this->getInt( 'limit', 0 );
@@ -813,8 +812,8 @@ class WebRequest {
                if ( $limit <= 0 ) {
                        $limit = $deflimit;
                }
-               if ( $limit > $hardlimit ) {
-                       $limit = $hardlimit; # We have *some* limits...
+               if ( $limit > 5000 ) {
+                       $limit = 5000; # We have *some* limits...
                }
 
                $offset = $this->getInt( 'offset', 0 );
@@ -1128,6 +1127,10 @@ HTML;
                        # unless the address is not sensible (e.g. private). However, prefer private
                        # IP addresses over proxy servers controlled by this site (more sensible).
                        foreach ( $ipchain as $i => $curIP ) {
+                               // ignore 'unknown' value from Squid when 'forwarded_for off' and try next
+                               if ( $curIP === 'unknown' ) {
+                                       continue;
+                               }
                                $curIP = IP::sanitizeIP( IP::canonicalize( $curIP ) );
                                if ( wfIsTrustedProxy( $curIP ) && isset( $ipchain[$i + 1] ) ) {
                                        if ( wfIsConfiguredProxy( $curIP ) || // bug 48919; treat IP as sane