Merge "Use the WebRequest::getCheck() shortcut where possible"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 29 Mar 2019 22:19:42 +0000 (22:19 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 29 Mar 2019 22:19:42 +0000 (22:19 +0000)
includes/EditPage.php
includes/MediaWiki.php
includes/api/ApiMain.php
includes/htmlform/fields/HTMLCheckField.php
includes/specials/SpecialSearch.php
mw-config/index.php

index 23cdc3b..d8fef17 100644 (file)
@@ -869,7 +869,7 @@ class EditPage {
                } elseif ( $this->section == 'new' ) {
                        // Nothing *to* preview for new sections
                        return false;
-               } elseif ( ( $request->getVal( 'preload' ) !== null || $this->mTitle->exists() )
+               } elseif ( ( $request->getCheck( 'preload' ) || $this->mTitle->exists() )
                        && $this->context->getUser()->getOption( 'previewonfirst' )
                ) {
                        // Standard preference behavior
@@ -975,7 +975,7 @@ class EditPage {
 
                        $this->scrolltop = $request->getIntOrNull( 'wpScrolltop' );
 
-                       if ( $this->textbox1 === '' && $request->getVal( 'wpTextbox1' ) === null ) {
+                       if ( $this->textbox1 === '' && !$request->getCheck( 'wpTextbox1' ) ) {
                                // wpTextbox1 field is missing, possibly due to being "too big"
                                // according to some filter rules such as Suhosin's setting for
                                // suhosin.request.max_value_length (d'oh)
index 43512e1..8cb9152 100644 (file)
@@ -330,7 +330,7 @@ class MediaWiki {
 
                if ( $request->getVal( 'action', 'view' ) != 'view'
                        || $request->wasPosted()
-                       || ( $request->getVal( 'title' ) !== null
+                       || ( $request->getCheck( 'title' )
                                && $title->getPrefixedDBkey() == $request->getVal( 'title' ) )
                        || count( $request->getValueNames( [ 'action', 'title' ] ) )
                        || !Hooks::run( 'TestCanonicalRedirect', [ $request, $title, $output ] )
index 295d5d0..261e4a4 100644 (file)
@@ -321,7 +321,7 @@ class ApiMain extends ApiBase {
                $request = $this->getRequest();
 
                // JSONP mode
-               if ( $request->getVal( 'callback' ) !== null ) {
+               if ( $request->getCheck( 'callback' ) ) {
                        $this->lacksSameOriginSecurity = true;
                        return true;
                }
index aad9f6e..0a1024c 100644 (file)
@@ -119,7 +119,7 @@ class HTMLCheckField extends HTMLFormField {
                // Fetch the value in either one of the two following case:
                // - we have a valid submit attempt (form was just submitted)
                // - we have a value (an URL manually built by the user, or GET form with no wpFormIdentifier)
-               if ( $this->isSubmitAttempt( $request ) || $request->getVal( $this->mName ) !== null ) {
+               if ( $this->isSubmitAttempt( $request ) || $request->getCheck( $this->mName ) ) {
                        return $invert
                                ? !$request->getBool( $this->mName )
                                : $request->getBool( $this->mName );
index 171566b..b60a2ad 100644 (file)
@@ -129,7 +129,7 @@ class SpecialSearch extends SpecialPage {
                $this->load();
                // TODO: This performs database actions on GET request, which is going to
                // be a problem for our multi-datacenter work.
-               if ( !is_null( $request->getVal( 'nsRemember' ) ) ) {
+               if ( $request->getCheck( 'nsRemember' ) ) {
                        $this->saveNamespaces();
                        // Remove the token from the URL to prevent the user from inadvertently
                        // exposing it (e.g. by pasting it into a public wiki page) or undoing
@@ -141,10 +141,7 @@ class SpecialSearch extends SpecialPage {
                }
 
                $this->searchEngineType = $request->getVal( 'srbackend' );
-               if (
-                       !$request->getVal( 'fulltext' ) &&
-                       $request->getVal( 'offset' ) === null
-               ) {
+               if ( !$request->getVal( 'fulltext' ) && !$request->getCheck( 'offset' ) ) {
                        $url = $this->goResult( $term );
                        if ( $url !== null ) {
                                // successful 'go'
index df3f6e5..b625c96 100644 (file)
@@ -63,7 +63,7 @@ function wfInstallerMain() {
                $session = array();
        }
 
-       if ( $request->getVal( 'uselang' ) !== null ) {
+       if ( $request->getCheck( 'uselang' ) ) {
                $langCode = $request->getVal( 'uselang' );
        } elseif ( isset( $session['settings']['_UserLang'] ) ) {
                $langCode = $session['settings']['_UserLang'];