From 83df6d8123e3b56af737ff0996157446f2b02639 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 9 Sep 2016 15:46:08 -0700 Subject: [PATCH] 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 --- includes/WebRequest.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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; } /** -- 2.20.1