* Added WebRequest::getFuzzyBool, which is a more JavaScript friendly version of getBool. Essentailly the same thing, except the string 'false' is also considered boolean false.
* Made use of getFuzzyBool where otherwise awkward and sometimes varied versions of 'flase' === false detection were being used.
This commit is contained in:
parent
c032accd70
commit
6de8690746
3 changed files with 17 additions and 4 deletions
|
|
@ -2286,7 +2286,7 @@ class OutputPage {
|
|||
// TODO: Divide off modules starting with "user", and add the user parameter to them
|
||||
$query = array(
|
||||
'lang' => $wgLang->getCode(),
|
||||
'debug' => ( $wgRequest->getBool( 'debug' ) && $wgRequest->getVal( 'debug' ) == 'true' ) ? 'true' : 'false',
|
||||
'debug' => $wgRequest->getFuzzyBool( 'debug' ) ? 'true' : 'false',
|
||||
'skin' => $wgUser->getSkin()->getSkinName(),
|
||||
'only' => $only,
|
||||
);
|
||||
|
|
@ -2357,7 +2357,7 @@ class OutputPage {
|
|||
$scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n";
|
||||
|
||||
// Script and Messages "only"
|
||||
if ( $wgRequest->getBool( 'debug' ) && $wgRequest->getVal( 'debug' ) !== 'false' ) {
|
||||
if ( $wgRequest->getFuzzyBool( 'debug' ) ) {
|
||||
// Scripts
|
||||
foreach ( $this->getModuleScripts() as $name ) {
|
||||
$scripts .= self::makeResourceLoaderLink( $sk, $name, 'scripts' );
|
||||
|
|
@ -2526,7 +2526,7 @@ class OutputPage {
|
|||
}
|
||||
|
||||
// Support individual script requests in debug mode
|
||||
if ( $wgRequest->getBool( 'debug' ) && $wgRequest->getVal( 'debug' ) !== 'false' ) {
|
||||
if ( $wgRequest->getFuzzyBool( 'debug' ) ) {
|
||||
foreach ( $this->getModuleStyles() as $name ) {
|
||||
$tags[] = self::makeResourceLoaderLink( $sk, $name, 'styles' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ResourceLoaderContext {
|
|||
$this->direction = $request->getVal( 'dir' );
|
||||
$this->skin = $request->getVal( 'skin' );
|
||||
$this->user = $request->getVal( 'user' );
|
||||
$this->debug = $request->getBool( 'debug' ) && $request->getVal( 'debug' ) === 'true';
|
||||
$this->debug = $request->getFuzzyBool( 'debug' );
|
||||
$this->only = $request->getVal( 'only' );
|
||||
$this->version = $request->getVal( 'version' );
|
||||
|
||||
|
|
|
|||
|
|
@ -347,6 +347,19 @@ class WebRequest {
|
|||
public function getBool( $name, $default = false ) {
|
||||
return $this->getVal( $name, $default ) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a boolean value from the input or return $default if not set.
|
||||
* Unlike getBool, the string "false" will result in boolean false, which is
|
||||
* useful when interpreting information sent from JavaScript.
|
||||
*
|
||||
* @param $name String
|
||||
* @param $default Boolean
|
||||
* @return Boolean
|
||||
*/
|
||||
public function getFuzzyBool( $name, $default = false ) {
|
||||
return $this->getBool( $name, $default ) && $this->getVal( $name ) !== 'false';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the named value is set in the input, whatever that
|
||||
|
|
|
|||
Loading…
Reference in a new issue