From: Timo Tijhof Date: Fri, 9 Sep 2016 22:46:08 +0000 (-0700) Subject: WebRequest: Use getRawVal instead of getGPCVal where possible X-Git-Tag: 1.31.0-rc.0~5638^2 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=83df6d8123e3b56af737ff0996157446f2b02639;p=lhc%2Fweb%2Fwiklou.git WebRequest: Use getRawVal instead of getGPCVal where possible Avoid getGPCVal() for simple methods that only need a boolean, number or specific string outcome. This saves overhead of touching $wgContLang or UtfNormal\Validator and makes load.php initialisation no longer depend on it. Change-Id: I8ce1fa31f5102b3fa18b0d0b9f56c42cb90146a1 --- diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 8f78164574..a5ae4612c6 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -520,7 +520,7 @@ class WebRequest { * @return int */ public function getInt( $name, $default = 0 ) { - return intval( $this->getVal( $name, $default ) ); + return intval( $this->getRawVal( $name, $default ) ); } /** @@ -532,7 +532,7 @@ class WebRequest { * @return int|null */ public function getIntOrNull( $name ) { - $val = $this->getVal( $name ); + $val = $this->getRawVal( $name ); return is_numeric( $val ) ? intval( $val ) : null; @@ -549,7 +549,7 @@ class WebRequest { * @return float */ public function getFloat( $name, $default = 0.0 ) { - return floatval( $this->getVal( $name, $default ) ); + return floatval( $this->getRawVal( $name, $default ) ); } /** @@ -562,7 +562,7 @@ class WebRequest { * @return bool */ public function getBool( $name, $default = false ) { - return (bool)$this->getVal( $name, $default ); + return (bool)$this->getRawVal( $name, $default ); } /** @@ -575,7 +575,8 @@ class WebRequest { * @return bool */ public function getFuzzyBool( $name, $default = false ) { - return $this->getBool( $name, $default ) && strcasecmp( $this->getVal( $name ), 'false' ) !== 0; + return $this->getBool( $name, $default ) + && strcasecmp( $this->getRawVal( $name ), 'false' ) !== 0; } /** @@ -589,7 +590,7 @@ class WebRequest { public function getCheck( $name ) { # Checkboxes and buttons are only present when clicked # Presence connotes truth, absence false - return $this->getVal( $name, null ) !== null; + return $this->getRawVal( $name, null ) !== null; } /**