Fix various phpcs error from last security patches
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 20 May 2016 18:11:58 +0000 (20:11 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 20 May 2016 18:20:36 +0000 (20:20 +0200)
Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs-trusty/1069/console

Breaking merges

Change-Id: If01b94705cd7b939ac380053730b1b602c838a8e

includes/Defines.php
includes/GlobalFunctions.php
includes/Linker.php
includes/WebStart.php
includes/api/ApiMain.php
includes/diff/DifferenceEngine.php
includes/parser/CoreTagHooks.php
tests/phpunit/includes/api/ApiMainTest.php

index 19a08ef..d2b3443 100644 (file)
@@ -309,5 +309,5 @@ define( 'CONTENT_FORMAT_XML', 'application/xml' );
 /**@{
  * Max string length for shell invocations; based on binfmts.h
  */
-define( 'SHELL_MAX_ARG_STRLEN', '100000');
+define( 'SHELL_MAX_ARG_STRLEN', '100000' );
 /**@}*/
index c5637ee..d5c6553 100644 (file)
@@ -2461,7 +2461,8 @@ function wfShellExec( $cmd, &$retval = null, $environ = [],
        // accomodating, because very long commands probably include user
        // input. See T129506.
        if ( strlen( $cmd ) > SHELL_MAX_ARG_STRLEN ) {
-               throw new Exception( __METHOD__ . '(): total length of $cmd must not exceed SHELL_MAX_ARG_STRLEN' );
+               throw new Exception( __METHOD__ .
+                       '(): total length of $cmd must not exceed SHELL_MAX_ARG_STRLEN' );
        }
 
        $desc = [
index b090817..3baf865 100644 (file)
@@ -1087,7 +1087,7 @@ class Linker {
                $newRel = Parser::getExternalLinkRel( $url, $title );
                if ( !isset( $attribs['rel'] ) || $attribs['rel'] === '' ) {
                        $attribs['rel'] = $newRel;
-               } elseif( $newRel !== '' ) {
+               } elseif ( $newRel !== '' ) {
                        // Merge the rel attributes.
                        $newRels = explode( ' ', $newRel );
                        $oldRels = explode( ' ', $attribs['rel'] );
index 8314e2e..d063ce3 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 if ( ini_get( 'mbstring.func_overload' ) ) {
-       die( 'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
+       die( 'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
 }
 
 # bug 15461: Make IE8 turn off content sniffing. Everybody else should ignore this
index b4354b9..60f2832 100644 (file)
@@ -273,11 +273,10 @@ class ApiMain extends ApiBase {
                }
 
                // Allow extensions to override.
-               $this->lacksSameOriginSecurity = !Hooks::run( 'RequestHasSameOriginSecurity', array( $request ) );
+               $this->lacksSameOriginSecurity = !Hooks::run( 'RequestHasSameOriginSecurity', [ $request ] );
                return $this->lacksSameOriginSecurity;
        }
 
-
        /**
         * Get the ApiErrorFormatter object associated with current request
         * @return ApiErrorFormatter
index 8985d51..f35356c 100644 (file)
@@ -474,16 +474,17 @@ class DifferenceEngine extends ContextSource {
                        if ( !$linkInfo ) {
                                $this->mMarkPatrolledLink = '';
                        } else {
-                               $this->mMarkPatrolledLink = ' <span class="patrollink" data-mw="interface">[' . Linker::linkKnown(
-                                       $this->mNewPage,
-                                       $this->msg( 'markaspatrolleddiff' )->escaped(),
-                                       [],
-                                       [
-                                               'action' => 'markpatrolled',
-                                               'rcid' => $linkInfo['rcid'],
-                                               'token' => $linkInfo['token'],
-                                       ]
-                               ) . ']</span>';
+                               $this->mMarkPatrolledLink = ' <span class="patrollink" data-mw="interface">[' .
+                                       Linker::linkKnown(
+                                               $this->mNewPage,
+                                               $this->msg( 'markaspatrolleddiff' )->escaped(),
+                                               [],
+                                               [
+                                                       'action' => 'markpatrolled',
+                                                       'rcid' => $linkInfo['rcid'],
+                                                       'token' => $linkInfo['token'],
+                                               ]
+                                       ) . ']</span>';
                        }
                }
                return $this->mMarkPatrolledLink;
index 4541c52..c943b7c 100644 (file)
@@ -59,8 +59,8 @@ class CoreTagHooks {
                // We need to let both '"' and '&' through,
                // for strip markers and entities respectively.
                $content = str_replace(
-                       array( '>', '<' ),
-                       array( '&gt;', '&lt;' ),
+                       [ '>', '<' ],
+                       [ '&gt;', '&lt;' ],
                        $content
                );
                return Html::rawElement( 'pre', $attribs, $content );
@@ -103,7 +103,7 @@ class CoreTagHooks {
         * @return array
         */
        public static function nowiki( $content, $attributes, $parser ) {
-               $content = strtr( $content, array(
+               $content = strtr( $content, [
                        // lang converter
                        '-{' => '-&#123;',
                        '}-' => '&#125;-',
@@ -112,8 +112,8 @@ class CoreTagHooks {
                        '>' => '&gt;'
                        // Note: Both '"' and '&' are not converted.
                        // This allows strip markers and entities through.
-               ) );
-               return array( $content, 'markerType' => 'nowiki' );
+               ] );
+               return [ $content, 'markerType' => 'nowiki' ];
        }
 
        /**
index 53554d7..334e3b8 100644 (file)
@@ -258,26 +258,28 @@ class ApiMainTest extends ApiTestCase {
         */
        public function testLacksSameOriginSecurity() {
                // Basic test
-               $main = new ApiMain( new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) ) );
+               $main = new ApiMain( new FauxRequest( [ 'action' => 'query', 'meta' => 'siteinfo' ] ) );
                $this->assertFalse( $main->lacksSameOriginSecurity(), 'Basic test, should have security' );
 
                // JSONp
                $main = new ApiMain(
-                       new FauxRequest( array( 'action' => 'query', 'format' => 'xml', 'callback' => 'foo'  ) )
+                       new FauxRequest( [ 'action' => 'query', 'format' => 'xml', 'callback' => 'foo' ] )
                );
                $this->assertTrue( $main->lacksSameOriginSecurity(), 'JSONp, should lack security' );
 
                // Header
-               $request = new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) );
+               $request = new FauxRequest( [ 'action' => 'query', 'meta' => 'siteinfo' ] );
                $request->setHeader( 'TrEaT-As-UnTrUsTeD', '' ); // With falsey value!
                $main = new ApiMain( $request );
                $this->assertTrue( $main->lacksSameOriginSecurity(), 'Header supplied, should lack security' );
 
                // Hook
-               $this->mergeMwGlobalArrayValue( 'wgHooks', array(
-                       'RequestHasSameOriginSecurity' => array( function () { return false; } )
-               ) );
-               $main = new ApiMain( new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) ) );
+               $this->mergeMwGlobalArrayValue( 'wgHooks', [
+                       'RequestHasSameOriginSecurity' => [ function () {
+                               return false;
+                       } ]
+               ] );
+               $main = new ApiMain( new FauxRequest( [ 'action' => 'query', 'meta' => 'siteinfo' ] ) );
                $this->assertTrue( $main->lacksSameOriginSecurity(), 'Hook, should lack security' );
        }
 }