else if -> elseif
authorumherirrender <umherirrender_de.wp@web.de>
Wed, 17 Apr 2013 14:52:47 +0000 (16:52 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Wed, 17 Apr 2013 14:52:47 +0000 (16:52 +0200)
Also fixed some spacing while at it
Added some braces for one line statements

Change-Id: Iebfa2b17091509daabc76248121c7763e2295d20

15 files changed:
includes/EditPage.php
includes/GlobalFunctions.php
includes/OutputPage.php
includes/Title.php
includes/content/ContentHandler.php
includes/db/DatabaseSqlite.php
includes/diff/DifferenceEngine.php
includes/installer/DatabaseUpdater.php
includes/resourceloader/ResourceLoader.php
maintenance/backup.inc
maintenance/createAndPromote.php
maintenance/language/languages.inc
maintenance/populateRevisionLength.php
maintenance/populateRevisionSha1.php
maintenance/update.php

index 6718442..ae35f3e 100644 (file)
@@ -898,7 +898,9 @@ class EditPage {
                                $orig = $this->getOriginalContent();
                                $content = $orig ? $orig->getSection( $this->section ) : null;
 
-                               if ( !$content ) $content = $def_content;
+                               if ( !$content ) {
+                                       $content = $def_content;
+                               }
                        } else {
                                $undoafter = $wgRequest->getInt( 'undoafter' );
                                $undo = $wgRequest->getInt( 'undo' );
@@ -986,7 +988,9 @@ class EditPage {
                }
                $revision = $this->mArticle->getRevisionFetched();
                if ( $revision === null ) {
-                       if ( !$this->contentModel ) $this->contentModel = $this->getTitle()->getContentModel();
+                       if ( !$this->contentModel ) {
+                               $this->contentModel = $this->getTitle()->getContentModel();
+                       }
                        $handler = ContentHandler::getForModelID( $this->contentModel );
 
                        return $handler->makeEmptyContent();
@@ -1008,7 +1012,9 @@ class EditPage {
                $content = $rev ? $rev->getContent( Revision::RAW ) : null;
 
                if ( $content === false || $content === null ) {
-                       if ( !$this->contentModel ) $this->contentModel = $this->getTitle()->getContentModel();
+                       if ( !$this->contentModel ) {
+                               $this->contentModel = $this->getTitle()->getContentModel();
+                       }
                        $handler = ContentHandler::getForModelID( $this->contentModel );
 
                        return $handler->makeEmptyContent();
@@ -1934,14 +1940,14 @@ class EditPage {
                if ( $namespace == NS_MEDIAWIKI ) {
                        # Show a warning if editing an interface message
                        $wgOut->wrapWikiMsg( "<div class='mw-editinginterface'>\n$1\n</div>", 'editinginterface' );
-               } else if( $namespace == NS_FILE ) {
+               } elseif ( $namespace == NS_FILE ) {
                        # Show a hint to shared repo
                        $file = wfFindFile( $this->mTitle );
-                       if( $file && !$file->isLocal() ) {
+                       if ( $file && !$file->isLocal() ) {
                                $descUrl = $file->getDescriptionUrl();
                                # there must be a description url to show a hint to shared repo
-                               if( $descUrl ) {
-                                       if( !$this->mTitle->exists() ) {
+                               if ( $descUrl ) {
+                                       if ( !$this->mTitle->exists() ) {
                                                $wgOut->wrapWikiMsg( "<div class=\"mw-sharedupload-desc-create\">\n$1\n</div>", array(
                                                                        'sharedupload-desc-create', $file->getRepo()->getDisplayName(), $descUrl
                                                ) );
@@ -2167,7 +2173,7 @@ class EditPage {
                }
 
                # When the summary is hidden, also hide them on preview/show changes
-               if( $this->nosummary ) {
+               if ( $this->nosummary ) {
                        $wgOut->addHTML( Html::hidden( 'nosummary', true ) );
                }
 
@@ -2708,9 +2714,9 @@ HTML
 
                $oldtitlemsg = 'currentrev';
                # if message does not exist, show diff against the preloaded default
-               if( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists() ) {
+               if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists() ) {
                        $oldtext = $this->mTitle->getDefaultMessageText();
-                       if( $oldtext !== false ) {
+                       if ( $oldtext !== false ) {
                                $oldtitlemsg = 'defaultmessagetext';
                                $oldContent = $this->toEditContent( $oldtext );
                        } else {
@@ -3034,9 +3040,9 @@ HTML
 
                        # don't parse non-wikitext pages, show message about preview
                        if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
-                               if( $this->mTitle->isCssJsSubpage() ) {
+                               if ( $this->mTitle->isCssJsSubpage() ) {
                                        $level = 'user';
-                               } elseif( $this->mTitle->isCssOrJsPage() ) {
+                               } elseif ( $this->mTitle->isCssOrJsPage() ) {
                                        $level = 'site';
                                } else {
                                        $level = false;
@@ -3052,7 +3058,7 @@ HTML
 
                                # Used messages to make sure grep find them:
                                # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
-                               if( $level && $format ) {
+                               if ( $level && $format ) {
                                        $note = "<div id='mw-{$level}{$format}preview'>" . wfMessage( "{$level}{$format}preview" )->text() . "</div>";
                                }
                        }
@@ -3512,7 +3518,7 @@ HTML
                global $wgOut, $wgLang;
                $this->textbox2 = $this->textbox1;
 
-               if( is_array( $match ) ) {
+               if ( is_array( $match ) ) {
                        $match = $wgLang->listToText( $match );
                }
                $wgOut->prepareErrorPage( wfMessage( 'spamprotectiontitle' ) );
index 0075bf5..458ab54 100644 (file)
@@ -35,7 +35,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  * PHP extensions may be included here.
  */
 
-if( !function_exists( 'iconv' ) ) {
+if ( !function_exists( 'iconv' ) ) {
        /**
         * @codeCoverageIgnore
         * @return string
@@ -73,7 +73,7 @@ if ( !function_exists( 'mb_strlen' ) ) {
        }
 }
 
-if( !function_exists( 'mb_strpos' ) ) {
+if ( !function_exists( 'mb_strpos' ) ) {
        /**
         * @codeCoverageIgnore
         * @return int
@@ -84,7 +84,7 @@ if( !function_exists( 'mb_strpos' ) ) {
 
 }
 
-if( !function_exists( 'mb_strrpos' ) ) {
+if ( !function_exists( 'mb_strrpos' ) ) {
        /**
         * @codeCoverageIgnore
         * @return int
@@ -138,7 +138,7 @@ function wfArrayDiff2_cmp( $a, $b ) {
        } else {
                reset( $a );
                reset( $b );
-               while( ( list( , $valueA ) = each( $a ) ) && ( list( , $valueB ) = each( $b ) ) ) {
+               while ( ( list( , $valueA ) = each( $a ) ) && ( list( , $valueB ) = each( $b ) ) ) {
                        $cmp = strcmp( $valueA, $valueB );
                        if ( $cmp !== 0 ) {
                                return $cmp;
@@ -262,7 +262,7 @@ function wfArrayInsertAfter( array $array, array $insert, $after ) {
  */
 function wfObjectToArray( $objOrArray, $recursive = true ) {
        $array = array();
-       if( is_object( $objOrArray ) ) {
+       if ( is_object( $objOrArray ) ) {
                $objOrArray = get_object_vars( $objOrArray );
        }
        foreach ( $objOrArray as $key => $value ) {
@@ -480,8 +480,8 @@ function wfAppendQuery( $url, $query ) {
        if ( is_array( $query ) ) {
                $query = wfArrayToCgi( $query );
        }
-       if( $query != '' ) {
-               if( false === strpos( $url, '?' ) ) {
+       if ( $query != '' ) {
+               if ( false === strpos( $url, '?' ) ) {
                        $url .= '?';
                } else {
                        $url .= '&';
@@ -1011,7 +1011,7 @@ function wfDebugTimer() {
  */
 function wfDebugMem( $exact = false ) {
        $mem = memory_get_usage();
-       if( !$exact ) {
+       if ( !$exact ) {
                $mem = floor( $mem / 1024 ) . ' kilobytes';
        } else {
                $mem .= ' bytes';
@@ -1031,7 +1031,7 @@ function wfDebugMem( $exact = false ) {
 function wfDebugLog( $logGroup, $text, $public = true ) {
        global $wgDebugLogGroups;
        $text = trim( $text ) . "\n";
-       if( isset( $wgDebugLogGroups[$logGroup] ) ) {
+       if ( isset( $wgDebugLogGroups[$logGroup] ) ) {
                $time = wfTimestamp( TS_DB );
                $wiki = wfWikiID();
                $host = wfHostname();
@@ -1310,27 +1310,27 @@ function wfReadOnlyReason() {
 function wfGetLangObj( $langcode = false ) {
        # Identify which language to get or create a language object for.
        # Using is_object here due to Stub objects.
-       if( is_object( $langcode ) ) {
+       if ( is_object( $langcode ) ) {
                # Great, we already have the object (hopefully)!
                return $langcode;
        }
 
        global $wgContLang, $wgLanguageCode;
-       if( $langcode === true || $langcode === $wgLanguageCode ) {
+       if ( $langcode === true || $langcode === $wgLanguageCode ) {
                # $langcode is the language code of the wikis content language object.
                # or it is a boolean and value is true
                return $wgContLang;
        }
 
        global $wgLang;
-       if( $langcode === false || $langcode === $wgLang->getCode() ) {
+       if ( $langcode === false || $langcode === $wgLang->getCode() ) {
                # $langcode is the language code of user language object.
                # or it was a boolean and value is false
                return $wgLang;
        }
 
        $validCodes = array_keys( Language::fetchLanguageNames() );
-       if( in_array( $langcode, $validCodes ) ) {
+       if ( in_array( $langcode, $validCodes ) ) {
                # $langcode corresponds to a valid language.
                return Language::factory( $langcode );
        }
@@ -1463,7 +1463,7 @@ function wfMsgForContent( $key ) {
        $args = func_get_args();
        array_shift( $args );
        $forcontent = true;
-       if( is_array( $wgForceUIMsgAsContentMsg ) &&
+       if ( is_array( $wgForceUIMsgAsContentMsg ) &&
                in_array( $key, $wgForceUIMsgAsContentMsg ) )
        {
                $forcontent = false;
@@ -1486,7 +1486,7 @@ function wfMsgForContentNoTrans( $key ) {
        $args = func_get_args();
        array_shift( $args );
        $forcontent = true;
-       if( is_array( $wgForceUIMsgAsContentMsg ) &&
+       if ( is_array( $wgForceUIMsgAsContentMsg ) &&
                in_array( $key, $wgForceUIMsgAsContentMsg ) )
        {
                $forcontent = false;
@@ -1535,7 +1535,7 @@ function wfMsgGetKey( $key, $useDB = true, $langCode = false, $transform = true
 
        $cache = MessageCache::singleton();
        $message = $cache->get( $key, $useDB, $langCode );
-       if( $message === false ) {
+       if ( $message === false ) {
                $message = '&lt;' . htmlspecialchars( $key ) . '&gt;';
        } elseif ( $transform ) {
                $message = $cache->transform( $message );
@@ -1562,7 +1562,7 @@ function wfMsgReplaceArgs( $message, $args ) {
                        $args = array_values( $args[0] );
                }
                $replacementKeys = array();
-               foreach( $args as $n => $param ) {
+               foreach ( $args as $n => $param ) {
                        $replacementKeys['$' . ( $n + 1 )] = $param;
                }
                $message = strtr( $message, $replacementKeys );
@@ -1646,11 +1646,11 @@ function wfMsgExt( $key, $options ) {
        array_shift( $args );
        $options = (array)$options;
 
-       foreach( $options as $arrayKey => $option ) {
-               if( !preg_match( '/^[0-9]+|language$/', $arrayKey ) ) {
+       foreach ( $options as $arrayKey => $option ) {
+               if ( !preg_match( '/^[0-9]+|language$/', $arrayKey ) ) {
                        # An unknown index, neither numeric nor "language"
                        wfWarn( "wfMsgExt called with incorrect parameter key $arrayKey", 1, E_USER_WARNING );
-               } elseif( preg_match( '/^[0-9]+$/', $arrayKey ) && !in_array( $option,
+               } elseif ( preg_match( '/^[0-9]+$/', $arrayKey ) && !in_array( $option,
                array( 'parse', 'parseinline', 'escape', 'escapenoentities',
                'replaceafter', 'parsemag', 'content' ) ) ) {
                        # A numeric index with unknown value
@@ -1658,11 +1658,11 @@ function wfMsgExt( $key, $options ) {
                }
        }
 
-       if( in_array( 'content', $options, true ) ) {
+       if ( in_array( 'content', $options, true ) ) {
                $forContent = true;
                $langCode = true;
                $langCodeObj = null;
-       } elseif( array_key_exists( 'language', $options ) ) {
+       } elseif ( array_key_exists( 'language', $options ) ) {
                $forContent = false;
                $langCode = wfGetLangObj( $options['language'] );
                $langCodeObj = $langCode;
@@ -1674,13 +1674,13 @@ function wfMsgExt( $key, $options ) {
 
        $string = wfMsgGetKey( $key, /*DB*/true, $langCode, /*Transform*/false );
 
-       if( !in_array( 'replaceafter', $options, true ) ) {
+       if ( !in_array( 'replaceafter', $options, true ) ) {
                $string = wfMsgReplaceArgs( $string, $args );
        }
 
        $messageCache = MessageCache::singleton();
        $parseInline = in_array( 'parseinline', $options, true );
-       if( in_array( 'parse', $options, true ) || $parseInline ) {
+       if ( in_array( 'parse', $options, true ) || $parseInline ) {
                $string = $messageCache->parse( $string, null, true, !$forContent, $langCodeObj );
                if ( $string instanceof ParserOutput ) {
                        $string = $string->getText();
@@ -1688,7 +1688,7 @@ function wfMsgExt( $key, $options ) {
 
                if ( $parseInline ) {
                        $m = array();
-                       if( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
+                       if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
                                $string = $m[1];
                        }
                }
@@ -1703,7 +1703,7 @@ function wfMsgExt( $key, $options ) {
                $string = Sanitizer::escapeHtmlAllowEntities( $string );
        }
 
-       if( in_array( 'replaceafter', $options, true ) ) {
+       if ( in_array( 'replaceafter', $options, true ) ) {
                $string = wfMsgReplaceArgs( $string, $args );
        }
 
@@ -1750,7 +1750,7 @@ function wfHostname() {
 
                # Hostname overriding
                global $wgOverrideHostname;
-               if( $wgOverrideHostname !== false ) {
+               if ( $wgOverrideHostname !== false ) {
                        # Set static and skip any detection
                        $host = $wgOverrideHostname;
                        return $host;
@@ -1762,7 +1762,7 @@ function wfHostname() {
                } else {
                        $uname = false;
                }
-               if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
+               if ( is_array( $uname ) && isset( $uname['nodename'] ) ) {
                        $host = $uname['nodename'];
                } elseif ( getenv( 'COMPUTERNAME' ) ) {
                        # Windows computer name
@@ -1809,7 +1809,7 @@ function wfReportTime() {
 function wfDebugBacktrace( $limit = 0 ) {
        static $disabled = null;
 
-       if( extension_loaded( 'Zend Optimizer' ) ) {
+       if ( extension_loaded( 'Zend Optimizer' ) ) {
                wfDebug( "Zend Optimizer detected; skipping debug_backtrace for safety.\n" );
                return array();
        }
@@ -1849,14 +1849,14 @@ function wfBacktrace() {
                $msg = "<ul>\n";
        }
        $backtrace = wfDebugBacktrace();
-       foreach( $backtrace as $call ) {
-               if( isset( $call['file'] ) ) {
+       foreach ( $backtrace as $call ) {
+               if ( isset( $call['file'] ) ) {
                        $f = explode( DIRECTORY_SEPARATOR, $call['file'] );
                        $file = $f[count( $f ) - 1];
                } else {
                        $file = '-';
                }
-               if( isset( $call['line'] ) ) {
+               if ( isset( $call['line'] ) ) {
                        $line = $call['line'];
                } else {
                        $line = '-';
@@ -1866,7 +1866,7 @@ function wfBacktrace() {
                } else {
                        $msg .= '<li>' . $file . ' line ' . $line . ' calls ';
                }
-               if( !empty( $call['class'] ) ) {
+               if ( !empty( $call['class'] ) ) {
                        $msg .= $call['class'] . $call['type'];
                }
                $msg .= $call['function'] . '()';
@@ -1964,11 +1964,11 @@ function wfViewPrevNext( $offset, $limit, $link, $query = '', $atend = false ) {
 
        $query = wfCgiToArray( $query );
 
-       if( is_object( $link ) ) {
+       if ( is_object( $link ) ) {
                $title = $link;
        } else {
                $title = Title::newFromText( $link );
-               if( is_null( $title ) ) {
+               if ( is_null( $title ) ) {
                        return false;
                }
        }
@@ -2004,16 +2004,16 @@ function wfClientAcceptsGzip( $force = false ) {
        static $result = null;
        if ( $result === null || $force ) {
                $result = false;
-               if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
+               if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
                        # @todo FIXME: We may want to blacklist some broken browsers
                        $m = array();
-                       if( preg_match(
+                       if ( preg_match(
                                '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/',
                                $_SERVER['HTTP_ACCEPT_ENCODING'],
                                $m )
                        )
                        {
-                               if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) {
+                               if ( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) {
                                        $result = false;
                                        return $result;
                                }
@@ -2166,14 +2166,14 @@ function wfHttpError( $code, $label, $desc ) {
  * @param $resetGzipEncoding Bool
  */
 function wfResetOutputBuffers( $resetGzipEncoding = true ) {
-       if( $resetGzipEncoding ) {
+       if ( $resetGzipEncoding ) {
                // Suppress Content-Encoding and Content-Length
                // headers from 1.10+s wfOutputHandler
                global $wgDisableOutputCompression;
                $wgDisableOutputCompression = true;
        }
-       while( $status = ob_get_status() ) {
-               if( $status['type'] == 0 /* PHP_OUTPUT_HANDLER_INTERNAL */ ) {
+       while ( $status = ob_get_status() ) {
+               if ( $status['type'] == 0 /* PHP_OUTPUT_HANDLER_INTERNAL */ ) {
                        // Probably from zlib.output_compression or other
                        // PHP-internal setting which can't be removed.
                        //
@@ -2181,13 +2181,13 @@ function wfResetOutputBuffers( $resetGzipEncoding = true ) {
                        // output behavior.
                        break;
                }
-               if( !ob_end_clean() ) {
+               if ( !ob_end_clean() ) {
                        // Could not remove output buffer handler; abort now
                        // to avoid getting in some kind of infinite loop.
                        break;
                }
-               if( $resetGzipEncoding ) {
-                       if( $status['name'] == 'ob_gzhandler' ) {
+               if ( $resetGzipEncoding ) {
+                       if ( $status['name'] == 'ob_gzhandler' ) {
                                // Reset the 'Content-Encoding' field set by this handler
                                // so we can start fresh.
                                header_remove( 'Content-Encoding' );
@@ -2223,7 +2223,7 @@ function wfClearOutputBuffers() {
  */
 function wfAcceptToPrefs( $accept, $def = '*/*' ) {
        # No arg means accept anything (per HTTP spec)
-       if( !$accept ) {
+       if ( !$accept ) {
                return array( $def => 1.0 );
        }
 
@@ -2231,7 +2231,7 @@ function wfAcceptToPrefs( $accept, $def = '*/*' ) {
 
        $parts = explode( ',', $accept );
 
-       foreach( $parts as $part ) {
+       foreach ( $parts as $part ) {
                # @todo FIXME: Doesn't deal with params like 'text/html; level=1'
                $values = explode( ';', trim( $part ) );
                $match = array();
@@ -2258,13 +2258,13 @@ function wfAcceptToPrefs( $accept, $def = '*/*' ) {
  * @private
  */
 function mimeTypeMatch( $type, $avail ) {
-       if( array_key_exists( $type, $avail ) ) {
+       if ( array_key_exists( $type, $avail ) ) {
                return $type;
        } else {
                $parts = explode( '/', $type );
-               if( array_key_exists( $parts[0] . '/*', $avail ) ) {
+               if ( array_key_exists( $parts[0] . '/*', $avail ) ) {
                        return $parts[0] . '/*';
-               } elseif( array_key_exists( '*/*', $avail ) ) {
+               } elseif ( array_key_exists( '*/*', $avail ) ) {
                        return '*/*';
                } else {
                        return null;
@@ -2288,21 +2288,21 @@ function mimeTypeMatch( $type, $avail ) {
 function wfNegotiateType( $cprefs, $sprefs ) {
        $combine = array();
 
-       foreach( array_keys( $sprefs ) as $type ) {
+       foreach ( array_keys( $sprefs ) as $type ) {
                $parts = explode( '/', $type );
-               if( $parts[1] != '*' ) {
+               if ( $parts[1] != '*' ) {
                        $ckey = mimeTypeMatch( $type, $cprefs );
-                       if( $ckey ) {
+                       if ( $ckey ) {
                                $combine[$type] = $sprefs[$type] * $cprefs[$ckey];
                        }
                }
        }
 
-       foreach( array_keys( $cprefs ) as $type ) {
+       foreach ( array_keys( $cprefs ) as $type ) {
                $parts = explode( '/', $type );
-               if( $parts[1] != '*' && !array_key_exists( $type, $sprefs ) ) {
+               if ( $parts[1] != '*' && !array_key_exists( $type, $sprefs ) ) {
                        $skey = mimeTypeMatch( $type, $sprefs );
-                       if( $skey ) {
+                       if ( $skey ) {
                                $combine[$type] = $sprefs[$skey] * $cprefs[$type];
                        }
                }
@@ -2311,8 +2311,8 @@ function wfNegotiateType( $cprefs, $sprefs ) {
        $bestq = 0;
        $besttype = null;
 
-       foreach( array_keys( $combine ) as $type ) {
-               if( $combine[$type] > $bestq ) {
+       foreach ( array_keys( $combine ) as $type ) {
+               if ( $combine[$type] > $bestq ) {
                        $besttype = $type;
                        $bestq = $combine[$type];
                }
@@ -2433,7 +2433,7 @@ function wfTimestamp( $outputtype = TS_UNIX, $ts = 0 ) {
  * @return String
  */
 function wfTimestampOrNull( $outputtype = TS_UNIX, $ts = null ) {
-       if( is_null( $ts ) ) {
+       if ( is_null( $ts ) ) {
                return null;
        } else {
                return wfTimestamp( $outputtype, $ts );
@@ -2504,8 +2504,8 @@ function wfTempDir() {
 
        $tmpDir = array_map( "getenv", array( 'TMPDIR', 'TMP', 'TEMP' ) );
 
-       foreach( $tmpDir as $tmp ) {
-               if( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
+       foreach ( $tmpDir as $tmp ) {
+               if ( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
                        return $tmp;
                }
        }
@@ -2532,7 +2532,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) {
                wfDebug( "$caller: called wfMkdirParents($dir)\n" );
        }
 
-       if( strval( $dir ) === '' || file_exists( $dir ) ) {
+       if ( strval( $dir ) === '' || file_exists( $dir ) ) {
                return true;
        }
 
@@ -2547,7 +2547,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) {
        $ok = mkdir( $dir, $mode, true ); // PHP5 <3
        wfRestoreWarnings();
 
-       if( !$ok ) {
+       if ( !$ok ) {
                // PHP doesn't report the path in its warning message, so add our own to aid in diagnosis.
                wfLogWarning( sprintf( "failed to mkdir \"%s\" mode 0%o", $dir, $mode ) );
        }
@@ -2600,7 +2600,9 @@ function wfPercent( $nr, $acc = 2, $round = true ) {
 function in_string( $needle, $str, $insensitive = false ) {
        wfDeprecated( __METHOD__, '1.21' );
        $func = 'strpos';
-       if( $insensitive ) $func = 'stripos';
+       if ( $insensitive ) {
+               $func = 'stripos';
+       }
 
        return $func( $str, $needle ) !== false;
 }
@@ -2647,19 +2649,19 @@ function wfIniGetBool( $setting ) {
  * @return Bool - Whether or not the extension is loaded
  */
 function wfDl( $extension, $fileName = null ) {
-       if( extension_loaded( $extension ) ) {
+       if ( extension_loaded( $extension ) ) {
                return true;
        }
 
        $canDl = false;
-       if( PHP_SAPI == 'cli' || PHP_SAPI == 'cgi' || PHP_SAPI == 'embed' ) {
+       if ( PHP_SAPI == 'cli' || PHP_SAPI == 'cgi' || PHP_SAPI == 'embed' ) {
                $canDl = ( function_exists( 'dl' ) && is_callable( 'dl' )
                && wfIniGetBool( 'enable_dl' ) && !wfIniGetBool( 'safe_mode' ) );
        }
 
-       if( $canDl ) {
+       if ( $canDl ) {
                $fileName = $fileName ? $fileName : $extension;
-               if( wfIsWindows() ) {
+               if ( wfIsWindows() ) {
                        $fileName = 'php_' . $fileName;
                }
                wfSuppressWarnings();
@@ -2752,7 +2754,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array
        static $disabled;
        if ( is_null( $disabled ) ) {
                $disabled = false;
-               if( wfIniGetBool( 'safe_mode' ) ) {
+               if ( wfIniGetBool( 'safe_mode' ) ) {
                        wfDebug( "wfShellExec can't run in safe_mode, PHP's exec functions are too broken.\n" );
                        $disabled = 'safemode';
                } else {
@@ -2775,7 +2777,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array
        wfInitShellLocale();
 
        $envcmd = '';
-       foreach( $environ as $k => $v ) {
+       foreach ( $environ as $k => $v ) {
                if ( wfIsWindows() ) {
                        /* Surrounding a set in quotes (method used by wfEscapeShellArg) makes the quotes themselves
                         * appear in the environment variable, so we must use carat escaping as documented in
@@ -2900,7 +2902,7 @@ function wfMerge( $old, $mine, $yours, &$result ) {
        $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
        wfRestoreWarnings();
 
-       if( !$haveDiff3 ) {
+       if ( !$haveDiff3 ) {
                wfDebug( "diff3 not found\n" );
                return false;
        }
@@ -2929,7 +2931,7 @@ function wfMerge( $old, $mine, $yours, &$result ) {
                wfEscapeShellArg( $yourtextName );
        $handle = popen( $cmd, 'r' );
 
-       if( fgets( $handle, 1024 ) ) {
+       if ( fgets( $handle, 1024 ) ) {
                $conflict = true;
        } else {
                $conflict = false;
@@ -2981,7 +2983,7 @@ function wfDiff( $before, $after, $params = '-u' ) {
 
        # This check may also protect against code injection in
        # case of broken installations.
-       if( !$haveDiff ) {
+       if ( !$haveDiff ) {
                wfDebug( "diff executable not found\n" );
                $diffs = new Diff( explode( "\n", $before ), explode( "\n", $after ) );
                $format = new UnifiedDiffFormatter();
@@ -3095,7 +3097,7 @@ function wfBaseName( $path, $suffix = '' ) {
                ? ''
                : ( '(?:' . preg_quote( $suffix, '#' ) . ')?' );
        $matches = array();
-       if( preg_match( "#([^/\\\\]*?){$encSuffix}[/\\\\]*$#", $path, $matches ) ) {
+       if ( preg_match( "#([^/\\\\]*?){$encSuffix}[/\\\\]*$#", $path, $matches ) ) {
                return $matches[1];
        } else {
                return '';
@@ -3123,21 +3125,21 @@ function wfRelativePath( $path, $from ) {
        $pieces = explode( DIRECTORY_SEPARATOR, dirname( $path ) );
        $against = explode( DIRECTORY_SEPARATOR, $from );
 
-       if( $pieces[0] !== $against[0] ) {
+       if ( $pieces[0] !== $against[0] ) {
                // Non-matching Windows drive letters?
                // Return a full path.
                return $path;
        }
 
        // Trim off common prefix
-       while( count( $pieces ) && count( $against )
+       while ( count( $pieces ) && count( $against )
                && $pieces[0] == $against[0] ) {
                array_shift( $pieces );
                array_shift( $against );
        }
 
        // relative dots to bump us to the parent
-       while( count( $against ) ) {
+       while ( count( $against ) ) {
                array_unshift( $pieces, '..' );
                array_shift( $against );
        }
@@ -3176,7 +3178,7 @@ function wfDoUpdates( $commit = '' ) {
  */
 function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = true, $engine = 'auto' ) {
        $input = (string)$input;
-       if(
+       if (
                $sourceBase < 2 ||
                $sourceBase > 36 ||
                $destBase < 2 ||
@@ -3204,39 +3206,39 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = t
                'u' => 30, 'v' => 31, 'w' => 32, 'x' => 33, 'y' => 34, 'z' => 35
        );
 
-       if( extension_loaded( 'gmp' ) && ( $engine == 'auto' || $engine == 'gmp' ) ) {
+       if ( extension_loaded( 'gmp' ) && ( $engine == 'auto' || $engine == 'gmp' ) ) {
                $result = gmp_strval( gmp_init( $input, $sourceBase ), $destBase );
-       } elseif( extension_loaded( 'bcmath' ) && ( $engine == 'auto' || $engine == 'bcmath' ) ) {
+       } elseif ( extension_loaded( 'bcmath' ) && ( $engine == 'auto' || $engine == 'bcmath' ) ) {
                $decimal = '0';
-               foreach( str_split( strtolower( $input ) ) as $char ) {
+               foreach ( str_split( strtolower( $input ) ) as $char ) {
                        $decimal = bcmul( $decimal, $sourceBase );
                        $decimal = bcadd( $decimal, $baseChars[$char] );
                }
 
-               for( $result = ''; bccomp( $decimal, 0 ); $decimal = bcdiv( $decimal, $destBase, 0 ) ) {
+               for ( $result = ''; bccomp( $decimal, 0 ); $decimal = bcdiv( $decimal, $destBase, 0 ) ) {
                        $result .= $baseChars[bcmod( $decimal, $destBase )];
                }
 
                $result = strrev( $result );
        } else {
                $inDigits = array();
-               foreach( str_split( strtolower( $input ) ) as $char ) {
+               foreach ( str_split( strtolower( $input ) ) as $char ) {
                        $inDigits[] = $baseChars[$char];
                }
 
                // Iterate over the input, modulo-ing out an output digit
                // at a time until input is gone.
                $result = '';
-               while( $inDigits ) {
+               while ( $inDigits ) {
                        $work = 0;
                        $workDigits = array();
 
                        // Long division...
-                       foreach( $inDigits as $digit ) {
+                       foreach ( $inDigits as $digit ) {
                                $work *= $sourceBase;
                                $work += $digit;
 
-                               if( $workDigits || $work >= $destBase ) {
+                               if ( $workDigits || $work >= $destBase ) {
                                        $workDigits[] = (int) ( $work / $destBase );
                                }
                                $work %= $destBase;
@@ -3253,7 +3255,7 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = t
                $result = strrev( $result );
        }
 
-       if( !$lowercase ) {
+       if ( !$lowercase ) {
                $result = strtoupper( $result );
        }
 
@@ -3279,9 +3281,9 @@ function wfCreateObject( $name, $p ) {
 function wfHttpOnlySafe() {
        global $wgHttpOnlyBlacklist;
 
-       if( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
-               foreach( $wgHttpOnlyBlacklist as $regex ) {
-                       if( preg_match( $regex, $_SERVER['HTTP_USER_AGENT'] ) ) {
+       if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
+               foreach ( $wgHttpOnlyBlacklist as $regex ) {
+                       if ( preg_match( $regex, $_SERVER['HTTP_USER_AGENT'] ) ) {
                                return false;
                        }
                }
@@ -3333,9 +3335,9 @@ function wfFixSessionID() {
 function wfSetupSession( $sessionId = false ) {
        global $wgSessionsInMemcached, $wgSessionsInObjectCache, $wgCookiePath, $wgCookieDomain,
                        $wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler;
-       if( $wgSessionsInObjectCache || $wgSessionsInMemcached ) {
+       if ( $wgSessionsInObjectCache || $wgSessionsInMemcached ) {
                ObjectCacheSessionHandler::install();
-       } elseif( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) {
+       } elseif ( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) {
                # Only set this if $wgSessionHandler isn't null and session.save_handler
                # hasn't already been set to the desired value (that causes errors)
                ini_set( 'session.save_handler', $wgSessionHandler );
@@ -3558,7 +3560,7 @@ function wfScript( $script = 'index' ) {
        global $wgScriptPath, $wgScriptExtension, $wgScript, $wgLoadScript;
        if ( $script === 'index' ) {
                return $wgScript;
-       } else if ( $script === 'load' ) {
+       } elseif ( $script === 'load' ) {
                return $wgLoadScript;
        } else {
                return "{$wgScriptPath}/{$script}{$wgScriptExtension}";
@@ -3571,7 +3573,7 @@ function wfScript( $script = 'index' ) {
  * @return string script URL
  */
 function wfGetScriptUrl() {
-       if( isset( $_SERVER['SCRIPT_NAME'] ) ) {
+       if ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
                #
                # as it was called, minus the query string.
                #
@@ -3716,9 +3718,9 @@ function wfStripIllegalFilenameChars( $name ) {
 function wfMemoryLimit() {
        global $wgMemoryLimit;
        $memlimit = wfShorthandToInteger( ini_get( 'memory_limit' ) );
-       if( $memlimit != -1 ) {
+       if ( $memlimit != -1 ) {
                $conflimit = wfShorthandToInteger( $wgMemoryLimit );
-               if( $conflimit == -1 ) {
+               if ( $conflimit == -1 ) {
                        wfDebug( "Removing PHP's memory limit\n" );
                        wfSuppressWarnings();
                        ini_set( 'memory_limit', $conflimit );
@@ -3743,7 +3745,7 @@ function wfMemoryLimit() {
  */
 function wfShorthandToInteger( $string = '' ) {
        $string = trim( $string );
-       if( $string === '' ) {
+       if ( $string === '' ) {
                return -1;
        }
        $last = $string[strlen( $string ) - 1];
@@ -3778,7 +3780,7 @@ function wfBCP47( $code ) {
        foreach ( $codeSegment as $segNo => $seg ) {
                if ( count( $codeSegment ) > 0 ) {
                        // when previous segment is x, it is a private segment and should be lc
-                       if( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) {
+                       if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) {
                                $codeBCP[$segNo] = strtolower( $seg );
                        // ISO 3166 country code
                        } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) {
@@ -3916,19 +3918,19 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
 
        # Handle redirects
        $redirectTitle = RepoGroup::singleton()->checkRedirect( Title::makeTitle( NS_FILE, $name ) );
-       if( $redirectTitle ) {
+       if ( $redirectTitle ) {
                $name = $redirectTitle->getDBkey();
        }
 
        # Run the extension hook
        $bad = false;
-       if( !wfRunHooks( 'BadImage', array( $name, &$bad ) ) ) {
+       if ( !wfRunHooks( 'BadImage', array( $name, &$bad ) ) ) {
                wfProfileOut( __METHOD__ );
                return $bad;
        }
 
        $cacheable = ( $blacklist === null );
-       if( $cacheable && $badImageCache !== null ) {
+       if ( $cacheable && $badImageCache !== null ) {
                $badImages = $badImageCache;
        } else { // cache miss
                if ( $blacklist === null ) {
@@ -3937,7 +3939,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
                # Build the list now
                $badImages = array();
                $lines = explode( "\n", $blacklist );
-               foreach( $lines as $line ) {
+               foreach ( $lines as $line ) {
                        # List items only
                        if ( substr( $line, 0, 1 ) !== '*' ) {
                                continue;
index 9f911d5..bf3c084 100644 (file)
@@ -319,7 +319,7 @@ class OutputPage extends ContextSource {
         * @param string $text or array of strings
         */
        function addKeyword( $text ) {
-               if( is_array( $text ) ) {
+               if ( is_array( $text ) ) {
                        $this->mKeywords = array_merge( $this->mKeywords, $text );
                } else {
                        array_push( $this->mKeywords, $text );
@@ -413,13 +413,14 @@ class OutputPage extends ContextSource {
        public function addScriptFile( $file, $version = null ) {
                global $wgStylePath, $wgStyleVersion;
                // See if $file parameter is an absolute URL or begins with a slash
-               if( substr( $file, 0, 1 ) == '/' || preg_match( '#^[a-z]*://#i', $file ) ) {
+               if ( substr( $file, 0, 1 ) == '/' || preg_match( '#^[a-z]*://#i', $file ) ) {
                        $path = $file;
                } else {
                        $path = "{$wgStylePath}/common/{$file}";
                }
-               if ( is_null( $version ) )
+               if ( is_null( $version ) ) {
                        $version = $wgStyleVersion;
+               }
                $this->addScript( Html::linkedScript( wfAppendQuery( $path, $version ) ) );
        }
 
@@ -452,9 +453,9 @@ class OutputPage extends ContextSource {
        protected function filterModules( $modules, $position = null, $type = ResourceLoaderModule::TYPE_COMBINED ) {
                $resourceLoader = $this->getResourceLoader();
                $filteredModules = array();
-               foreach( $modules as $val ) {
+               foreach ( $modules as $val ) {
                        $module = $resourceLoader->getModule( $val );
-                       if( $module instanceof ResourceLoaderModule
+                       if ( $module instanceof ResourceLoaderModule
                                && $module->getOrigin() <= $this->getAllowedModules( $type )
                                && ( is_null( $position ) || $module->getPosition() == $position )
                                && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) ) )
@@ -693,20 +694,20 @@ class OutputPage extends ContextSource {
                        wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" );
                        return false;
                }
-               if( !$wgCachePages ) {
+               if ( !$wgCachePages ) {
                        wfDebug( __METHOD__ . ": CACHE DISABLED\n", false );
                        return false;
                }
-               if( $this->getUser()->getOption( 'nocache' ) ) {
+               if ( $this->getUser()->getOption( 'nocache' ) ) {
                        wfDebug( __METHOD__ . ": USER DISABLED CACHE\n", false );
                        return false;
                }
 
                $timestamp = wfTimestamp( TS_MW, $timestamp );
                $modifiedTimes = array(
-                       'page'   => $timestamp,
-                       'user'   => $this->getUser()->getTouched(),
-                       'epoch'  => $wgCacheEpoch
+                       'page' => $timestamp,
+                       'user' => $this->getUser()->getTouched(),
+                       'epoch' => $wgCacheEpoch
                );
                if ( $wgUseSquid ) {
                        // bug 44570: the core page itself may not change, but resources might
@@ -750,7 +751,7 @@ class OutputPage extends ContextSource {
                        wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", false );
                wfDebug( __METHOD__ . ": effective Last-Modified: " .
                        wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", false );
-               if( $clientHeaderTime < $maxModified ) {
+               if ( $clientHeaderTime < $maxModified ) {
                        wfDebug( __METHOD__ . ": STALE, $info\n", false );
                        return false;
                }
@@ -792,10 +793,10 @@ class OutputPage extends ContextSource {
        public function setRobotPolicy( $policy ) {
                $policy = Article::formatRobotPolicy( $policy );
 
-               if( isset( $policy['index'] ) ) {
+               if ( isset( $policy['index'] ) ) {
                        $this->setIndexPolicy( $policy['index'] );
                }
-               if( isset( $policy['follow'] ) ) {
+               if ( isset( $policy['follow'] ) ) {
                        $this->setFollowPolicy( $policy['follow'] );
                }
        }
@@ -809,7 +810,7 @@ class OutputPage extends ContextSource {
         */
        public function setIndexPolicy( $policy ) {
                $policy = trim( $policy );
-               if( in_array( $policy, array( 'index', 'noindex' ) ) ) {
+               if ( in_array( $policy, array( 'index', 'noindex' ) ) ) {
                        $this->mIndexPolicy = $policy;
                }
        }
@@ -823,7 +824,7 @@ class OutputPage extends ContextSource {
         */
        public function setFollowPolicy( $policy ) {
                $policy = trim( $policy );
-               if( in_array( $policy, array( 'follow', 'nofollow' ) ) ) {
+               if ( in_array( $policy, array( 'follow', 'nofollow' ) ) ) {
                        $this->mFollowPolicy = $policy;
                }
        }
@@ -1310,7 +1311,7 @@ class OutputPage extends ContextSource {
         * @return Int ResourceLoaderModule ORIGIN_ class constant
         */
        public function getAllowedModules( $type ) {
-               if( $type == ResourceLoaderModule::TYPE_COMBINED ) {
+               if ( $type == ResourceLoaderModule::TYPE_COMBINED ) {
                        return min( array_values( $this->mAllowedModules ) );
                } else {
                        return isset( $this->mAllowedModules[$type] )
@@ -1652,7 +1653,7 @@ class OutputPage extends ContextSource {
        public function parse( $text, $linestart = true, $interface = false, $language = null ) {
                global $wgParser;
 
-               if( is_null( $this->getTitle() ) ) {
+               if ( is_null( $this->getTitle() ) ) {
                        throw new MWException( 'Empty $mTitle in ' . __METHOD__ );
                }
 
@@ -1776,8 +1777,8 @@ class OutputPage extends ContextSource {
        public function addVaryHeader( $header, $option = null ) {
                if ( !array_key_exists( $header, $this->mVaryHeader ) ) {
                        $this->mVaryHeader[$header] = (array)$option;
-               } elseif( is_array( $option ) ) {
-                       if( is_array( $this->mVaryHeader[$header] ) ) {
+               } elseif ( is_array( $option ) ) {
+                       if ( is_array( $this->mVaryHeader[$header] ) ) {
                                $this->mVaryHeader[$header] = array_merge( $this->mVaryHeader[$header], $option );
                        } else {
                                $this->mVaryHeader[$header] = $option;
@@ -1811,7 +1812,7 @@ class OutputPage extends ContextSource {
                $this->addVaryHeader( 'Cookie', $cookiesOption );
 
                $headers = array();
-               foreach( $this->mVaryHeader as $header => $option ) {
+               foreach ( $this->mVaryHeader as $header => $option ) {
                        $newheader = $header;
                        if ( is_array( $option ) && count( $option ) > 0 ) {
                                $newheader .= ';' . implode( ';', $option );
@@ -1833,11 +1834,11 @@ class OutputPage extends ContextSource {
         */
        function addAcceptLanguage() {
                $lang = $this->getTitle()->getPageLanguage();
-               if( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) {
+               if ( !$this->getRequest()->getCheck( 'variant' ) && $lang->hasVariants() ) {
                        $variants = $lang->getVariants();
                        $aloption = array();
                        foreach ( $variants as $variant ) {
-                               if( $variant === $lang->getCode() ) {
+                               if ( $variant === $lang->getCode() ) {
                                        continue;
                                } else {
                                        $aloption[] = 'string-contains=' . $variant;
@@ -1918,12 +1919,11 @@ class OutputPage extends ContextSource {
                        $response->header( $this->getXVO() );
                }
 
-               if( $this->mEnableClientCache ) {
-                       if(
+               if ( $this->mEnableClientCache ) {
+                       if (
                                $wgUseSquid && session_id() == '' && !$this->isPrintable() &&
                                $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies()
-                       )
-                       {
+                       ) {
                                if ( $wgUseESI ) {
                                        # We'll purge the proxy cache explicitly, but require end user agents
                                        # to revalidate against the proxy on each visit.
@@ -1950,7 +1950,7 @@ class OutputPage extends ContextSource {
                                $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
                                $response->header( "Cache-Control: private, must-revalidate, max-age=0" );
                        }
-                       if( $this->mLastModified ) {
+                       if ( $this->mLastModified ) {
                                $response->header( "Last-Modified: {$this->mLastModified}" );
                        }
                } else {
@@ -1985,7 +1985,7 @@ class OutputPage extends ContextSource {
        public function output() {
                global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP;
 
-               if( $this->mDoNothing ) {
+               if ( $this->mDoNothing ) {
                        return;
                }
 
@@ -2000,9 +2000,9 @@ class OutputPage extends ContextSource {
                        $redirect = $this->mRedirect;
                        $code = $this->mRedirectCode;
 
-                       if( wfRunHooks( "BeforePageRedirect", array( $this, &$redirect, &$code ) ) ) {
-                               if( $code == '301' || $code == '303' ) {
-                                       if( !$wgDebugRedirects ) {
+                       if ( wfRunHooks( "BeforePageRedirect", array( $this, &$redirect, &$code ) ) ) {
+                               if ( $code == '301' || $code == '303' ) {
+                                       if ( !$wgDebugRedirects ) {
                                                $message = HttpStatus::getMessage( $code );
                                                $response->header( "HTTP/1.1 $code $message" );
                                        }
@@ -2014,7 +2014,7 @@ class OutputPage extends ContextSource {
                                $this->sendCacheControl();
 
                                $response->header( "Content-Type: text/html; charset=utf-8" );
-                               if( $wgDebugRedirects ) {
+                               if ( $wgDebugRedirects ) {
                                        $url = htmlspecialchars( $redirect );
                                        print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
                                        print "<p>Location: <a href=\"$url\">$url</a></p>\n";
@@ -2123,7 +2123,7 @@ class OutputPage extends ContextSource {
         * @param array $params message parameters; ignored if $msg is a Message object
         */
        public function showErrorPage( $title, $msg, $params = array() ) {
-               if( !$title instanceof Message ) {
+               if ( !$title instanceof Message ) {
                        $title = $this->msg( $title );
                }
 
@@ -2264,7 +2264,7 @@ class OutputPage extends ContextSource {
                if ( count( $errors ) > 1 ) {
                        $text .= '<ul class="permissions-errors">' . "\n";
 
-                       foreach( $errors as $error ) {
+                       foreach ( $errors as $error ) {
                                $text .= '<li>';
                                $text .= call_user_func_array( array( $this, 'msg' ), $error )->plain();
                                $text .= "</li>\n";
@@ -2312,7 +2312,7 @@ class OutputPage extends ContextSource {
 
                if ( !empty( $reasons ) ) {
                        // Permissions error
-                       if( $source ) {
+                       if ( $source ) {
                                $this->setPageTitle( $this->msg( 'viewsource-title', $this->getTitle()->getPrefixedText() ) );
                                $this->addBacklinkSubtitle( $this->getTitle() );
                        } else {
@@ -2325,7 +2325,7 @@ class OutputPage extends ContextSource {
                }
 
                // Show source, if supplied
-               if( is_string( $source ) ) {
+               if ( is_string( $source ) ) {
                        $this->addWikiMsg( 'viewsourcetext' );
 
                        $pageLang = $this->getTitle()->getPageLanguage();
@@ -2351,7 +2351,7 @@ $templates
                # If the title doesn't exist, it's fairly pointless to print a return
                # link to it.  After all, you just tried editing it and couldn't, so
                # what's there to do there?
-               if( $this->getTitle()->exists() ) {
+               if ( $this->getTitle()->exists() ) {
                        $this->returnToMain( null, $this->getTitle() );
                }
        }
@@ -2375,7 +2375,7 @@ $templates
         */
        public function showLagWarning( $lag ) {
                global $wgSlaveLagWarning, $wgSlaveLagCritical;
-               if( $lag >= $wgSlaveLagWarning ) {
+               if ( $lag >= $wgSlaveLagWarning ) {
                        $message = $lag < $wgSlaveLagCritical
                                ? 'lag-warn-normal'
                                : 'lag-warn-high';
@@ -2419,9 +2419,9 @@ $templates
         * @param $options Options array to pass to Linker
         */
        public function addReturnTo( $title, $query = array(), $text = null, $options = array() ) {
-               if( in_array( 'http', $options ) ) {
+               if ( in_array( 'http', $options ) ) {
                        $proto = PROTO_HTTP;
-               } elseif( in_array( 'https', $options ) ) {
+               } elseif ( in_array( 'https', $options ) ) {
                        $proto = PROTO_HTTPS;
                } else {
                        $proto = PROTO_RELATIVE;
@@ -2556,7 +2556,7 @@ $templates
 
                        wfRunHooks( 'AjaxAddScript', array( &$this ) );
 
-                       if( $wgAjaxWatch && $this->getUser()->isLoggedIn() ) {
+                       if ( $wgAjaxWatch && $this->getUser()->isLoggedIn() ) {
                                $this->addModules( 'mediawiki.page.watch.ajax' );
                        }
 
@@ -2756,7 +2756,7 @@ $templates
                                // Automatically select style/script elements
                                if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
                                        $link = Html::linkedStyle( $url );
-                               } else if ( $loadCall ) {
+                               } elseif ( $loadCall ) {
                                        $link = Html::inlineScript(
                                                ResourceLoader::makeLoaderConditionalScript(
                                                        Xml::encodeJsCall( 'mw.loader.load', array( $url, 'text/javascript', true ) )
@@ -2767,7 +2767,7 @@ $templates
                                }
                        }
 
-                       if( $group == 'noscript' ) {
+                       if ( $group == 'noscript' ) {
                                $links .= Html::rawElement( 'noscript', array(), $link ) . "\n";
                        } else {
                                $links .= $link . "\n";
@@ -2878,7 +2878,7 @@ $templates
                // Add user JS if enabled
                if ( $wgAllowUserJs ) {
                        if ( $this->getUser()->isLoggedIn() ) {
-                               if( $this->getTitle() && $this->getTitle()->isJsSubpage() && $this->userCanPreview() ) {
+                               if ( $this->getTitle() && $this->getTitle()->isJsSubpage() && $this->userCanPreview() ) {
                                        # XXX: additional security check/prompt?
                                        // We're on a preview of a JS subpage
                                        // Exclude this page from the user module in case it's in there (bug 26283)
@@ -3141,7 +3141,7 @@ $templates
                ) );
 
                $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
-               if( $p !== 'index,follow' ) {
+               if ( $p !== 'index,follow' ) {
                        // http://www.robotstxt.org/wc/meta-user.html
                        // Only show if it's different from the default robots policy
                        $tags['meta-robots'] = Html::element( 'meta', array(
@@ -3289,7 +3289,7 @@ $templates
 
                # Feeds
                if ( $wgFeed ) {
-                       foreach( $this->getSyndicationLinks() as $format => $link ) {
+                       foreach ( $this->getSyndicationLinks() as $format => $link ) {
                                # Use the page name for the title.  In principle, this could
                                # lead to issues with having the same name for different feeds
                                # corresponding to the same page, but we can't avoid that at
@@ -3391,13 +3391,13 @@ $templates
                $options = array();
                // Even though we expect the media type to be lowercase, but here we
                // force it to lowercase to be safe.
-               if( $media ) {
+               if ( $media ) {
                        $options['media'] = $media;
                }
-               if( $condition ) {
+               if ( $condition ) {
                        $options['condition'] = $condition;
                }
-               if( $dir ) {
+               if ( $dir ) {
                        $options['dir'] = $dir;
                }
                $this->styles[$style] = $options;
@@ -3409,7 +3409,7 @@ $templates
         * @param string $flip Set to 'flip' to flip the CSS if needed
         */
        public function addInlineStyle( $style_css, $flip = 'noflip' ) {
-               if( $flip === 'flip' && $this->getLanguage()->isRTL() ) {
+               if ( $flip === 'flip' && $this->getLanguage()->isRTL() ) {
                        # If wanted, and the interface is right-to-left, flip the CSS
                        $style_css = CSSJanus::transform( $style_css, true, false );
                }
@@ -3439,7 +3439,7 @@ $templates
                if ( $wgUseSiteCss ) {
                        $moduleStyles[] = 'site';
                        $moduleStyles[] = 'noscript';
-                       if( $this->getUser()->isLoggedIn() ) {
+                       if ( $this->getUser()->isLoggedIn() ) {
                                $moduleStyles[] = 'user.groups';
                        }
                }
@@ -3520,9 +3520,9 @@ $templates
                }
                $this->mExtStyles = array();
 
-               foreach( $this->styles as $file => $options ) {
+               foreach ( $this->styles as $file => $options ) {
                        $link = $this->styleLink( $file, $options );
-                       if( $link ) {
+                       if ( $link ) {
                                $links[$file] = $link;
                        }
                }
@@ -3538,22 +3538,22 @@ $templates
         * @return String: HTML fragment
         */
        protected function styleLink( $style, $options ) {
-               if( isset( $options['dir'] ) ) {
-                       if( $this->getLanguage()->getDir() != $options['dir'] ) {
+               if ( isset( $options['dir'] ) ) {
+                       if ( $this->getLanguage()->getDir() != $options['dir'] ) {
                                return '';
                        }
                }
 
-               if( isset( $options['media'] ) ) {
+               if ( isset( $options['media'] ) ) {
                        $media = self::transformCssMedia( $options['media'] );
-                       if( is_null( $media ) ) {
+                       if ( is_null( $media ) ) {
                                return '';
                        }
                } else {
                        $media = 'all';
                }
 
-               if( substr( $style, 0, 1 ) == '/' ||
+               if ( substr( $style, 0, 1 ) == '/' ||
                        substr( $style, 0, 5 ) == 'http:' ||
                        substr( $style, 0, 6 ) == 'https:' ) {
                        $url = $style;
@@ -3564,7 +3564,7 @@ $templates
 
                $link = Html::linkedStyle( $url, $media );
 
-               if( isset( $options['condition'] ) ) {
+               if ( isset( $options['condition'] ) ) {
                        $condition = htmlspecialchars( $options['condition'] );
                        $link = "<!--[if $condition]>$link<![endif]-->";
                }
@@ -3589,11 +3589,11 @@ $templates
                        'printable' => 'print',
                        'handheld' => 'handheld',
                );
-               foreach( $switches as $switch => $targetMedia ) {
-                       if( $wgRequest->getBool( $switch ) ) {
-                               if( $media == $targetMedia ) {
+               foreach ( $switches as $switch => $targetMedia ) {
+                       if ( $wgRequest->getBool( $switch ) ) {
+                               if ( $media == $targetMedia ) {
                                        $media = '';
-                               } elseif( preg_match( $screenMediaQueryRegex, $media ) === 1 ) {
+                               } elseif ( preg_match( $screenMediaQueryRegex, $media ) === 1 ) {
                                        // This regex will not attempt to understand a comma-separated media_query_list
                                        //
                                        // Example supported values for $media: 'screen', 'only screen', 'screen and (min-width: 982px)' ),
@@ -3604,7 +3604,7 @@ $templates
                                        // we don't want simple 'screen' but we might want screen queries that
                                        // have a max-width or something, so we'll pass all others on and let the
                                        // client do the query.
-                                       if( $targetMedia == 'print' || $media == 'screen' ) {
+                                       if ( $targetMedia == 'print' || $media == 'screen' ) {
                                                return null;
                                        }
                                }
@@ -3612,13 +3612,13 @@ $templates
                }
 
                // Expand longer media queries as iPhone doesn't grok 'handheld'
-               if( $wgHandheldForIPhone ) {
+               if ( $wgHandheldForIPhone ) {
                        $mediaAliases = array(
                                'screen' => 'screen and (min-device-width: 481px)',
                                'handheld' => 'handheld, only screen and (max-device-width: 480px)',
                        );
 
-                       if( isset( $mediaAliases[$media] ) ) {
+                       if ( isset( $mediaAliases[$media] ) ) {
                                $media = $mediaAliases[$media];
                        }
                }
index aa8fb93..d0ac97b 100644 (file)
@@ -289,18 +289,23 @@ class Title {
         */
        public function loadFromRow( $row ) {
                if ( $row ) { // page found
-                       if ( isset( $row->page_id ) )
+                       if ( isset( $row->page_id ) ) {
                                $this->mArticleID = (int)$row->page_id;
-                       if ( isset( $row->page_len ) )
+                       }
+                       if ( isset( $row->page_len ) ) {
                                $this->mLength = (int)$row->page_len;
-                       if ( isset( $row->page_is_redirect ) )
+                       }
+                       if ( isset( $row->page_is_redirect ) ) {
                                $this->mRedirect = (bool)$row->page_is_redirect;
-                       if ( isset( $row->page_latest ) )
+                       }
+                       if ( isset( $row->page_latest ) ) {
                                $this->mLatestID = (int)$row->page_latest;
-                       if ( isset( $row->page_content_model ) )
+                       }
+                       if ( isset( $row->page_content_model ) ) {
                                $this->mContentModel = strval( $row->page_content_model );
-                       else
+                       } else {
                                $this->mContentModel = false; # initialized lazily in getContentModel()
+                       }
                } else { // page not found
                        $this->mArticleID = 0;
                        $this->mLength = 0;
@@ -689,7 +694,7 @@ class Title {
                        $this->mContentModel = ContentHandler::getDefaultModelFor( $this );
                }
 
-               if( !$this->mContentModel ) {
+               if ( !$this->mContentModel ) {
                        throw new MWException( 'Failed to determine content model!' );
                }
 
@@ -997,8 +1002,9 @@ class Title {
                $subpage = explode( '/', $this->mTextform );
                $subpage = $subpage[count( $subpage ) - 1];
                $lastdot = strrpos( $subpage, '.' );
-               if ( $lastdot === false )
+               if ( $lastdot === false ) {
                        return $subpage; # Never happens: only called for names ending in '.css' or '.js'
+               }
                return substr( $subpage, 0, $lastdot );
        }
 
@@ -1340,7 +1346,7 @@ class Title {
         * @return String
         */
        private static function fixUrlQueryArgs( $query, $query2 = false ) {
-               if( $query2 !== false ) {
+               if ( $query2 !== false ) {
                        wfDeprecated( "Title::get{Canonical,Full,Link,Local,Internal}URL " .
                                "method called with a second parameter is deprecated. Add your " .
                                "parameter to an array passed as the first parameter.", "1.19" );
@@ -1954,8 +1960,9 @@ class Title {
                                        $right = ( $right == 'sysop' ) ? 'protect' : $right;
                                        if ( $right != '' && !$user->isAllowed( $right ) ) {
                                                $pages = '';
-                                               foreach ( $cascadingSources as $page )
+                                               foreach ( $cascadingSources as $page ) {
                                                        $pages .= '* [[:' . $page->getPrefixedText() . "]]\n";
+                                               }
                                                $errors[] = array( 'cascadeprotected', count( $cascadingSources ), $pages );
                                        }
                                }
@@ -1986,11 +1993,11 @@ class Title {
                        }
                } elseif ( $action == 'create' ) {
                        $title_protection = $this->getTitleProtection();
-                       if( $title_protection ) {
-                               if( $title_protection['pt_create_perm'] == 'sysop' ) {
+                       if ( $title_protection ) {
+                               if ( $title_protection['pt_create_perm'] == 'sysop' ) {
                                        $title_protection['pt_create_perm'] = 'protect'; // B/C
                                }
-                               if( $title_protection['pt_create_perm'] == '' ||
+                               if ( $title_protection['pt_create_perm'] == '' ||
                                        !$user->isAllowed( $title_protection['pt_create_perm'] ) )
                                {
                                        $errors[] = array( 'titleprotected', User::whoIs( $title_protection['pt_user'] ), $title_protection['pt_reason'] );
@@ -2035,7 +2042,7 @@ class Title {
        private function checkUserBlock( $action, $user, $errors, $doExpensiveQueries, $short ) {
                // Account creation blocks handled at userlogin.
                // Unblocking handled in SpecialUnblock
-               if( !$doExpensiveQueries || in_array( $action, array( 'createaccount', 'unblock' ) ) ) {
+               if ( !$doExpensiveQueries || in_array( $action, array( 'createaccount', 'unblock' ) ) ) {
                        return $errors;
                }
 
@@ -2048,7 +2055,7 @@ class Title {
                if ( ( $action == 'edit' || $action == 'create' ) && !$user->isBlockedFrom( $this ) ) {
                        // Don't block the user from editing their own talk page unless they've been
                        // explicitly blocked from that too.
-               } elseif( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
+               } elseif ( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
                        $block = $user->getBlock();
 
                        // This is from OutputPage::blockedPage
@@ -2166,7 +2173,7 @@ class Title {
                        }
                }
 
-               if( !$whitelisted && is_array( $wgWhitelistReadRegexp ) && !empty( $wgWhitelistReadRegexp ) ) {
+               if ( !$whitelisted && is_array( $wgWhitelistReadRegexp ) && !empty( $wgWhitelistReadRegexp ) ) {
                        $name = $this->getPrefixedText();
                        // Check for regex whitelisting
                        foreach ( $wgWhitelistReadRegexp as $listItem ) {
@@ -2251,7 +2258,7 @@ class Title {
                }
 
                $errors = array();
-               while( count( $checks ) > 0 &&
+               while ( count( $checks ) > 0 &&
                                !( $short && count( $errors ) > 0 ) ) {
                        $method = array_shift( $checks );
                        $errors = $this->$method( $action, $user, $errors, $doExpensiveQueries, $short );
@@ -2446,7 +2453,7 @@ class Title {
                $restrictionTypes = $this->getRestrictionTypes();
 
                # Special pages have inherent protection
-               if( $this->isSpecialPage() ) {
+               if ( $this->isSpecialPage() ) {
                        return true;
                }
 
@@ -2693,7 +2700,7 @@ class Title {
                                        $this->mRestrictions['move'] = explode( ',', trim( $temp[0] ) );
                                } else {
                                        $restriction = trim( $temp[1] );
-                                       if( $restriction != '' ) { //some old entries are empty
+                                       if ( $restriction != '' ) { //some old entries are empty
                                                $this->mRestrictions[$temp[0]] = explode( ',', $restriction );
                                        }
                                }
@@ -2712,8 +2719,9 @@ class Title {
                        foreach ( $rows as $row ) {
 
                                // Don't take care of restrictions types that aren't allowed
-                               if ( !in_array( $row->pr_type, $restrictionTypes ) )
+                               if ( !in_array( $row->pr_type, $restrictionTypes ) ) {
                                        continue;
+                               }
 
                                // This code should be refactored, now that it's being used more generally,
                                // But I don't really see any harm in leaving it in Block for now -werdna
@@ -3302,7 +3310,7 @@ class Title {
                        array(
                                "{$prefix}_from=page_id",
                                "{$prefix}_namespace" => $this->getNamespace(),
-                               "{$prefix}_title"     => $this->getDBkey() ),
+                               "{$prefix}_title" => $this->getDBkey() ),
                        __METHOD__,
                        $options
                );
@@ -3367,7 +3375,9 @@ class Title {
                $titleField = "{$prefix}_title";
 
                $fields = array( $namespaceFiled, $titleField, 'page_id', 'page_len', 'page_is_redirect', 'page_latest' );
-               if ( $wgContentHandlerUseDB ) $fields[] = 'page_content_model';
+               if ( $wgContentHandlerUseDB ) {
+                       $fields[] = 'page_content_model';
+               }
 
                $res = $db->select(
                        array( $table, 'page' ),
@@ -3712,12 +3722,12 @@ class Title {
                        # Protect the redirect title as the title used to be...
                        $dbw->insertSelect( 'page_restrictions', 'page_restrictions',
                                array(
-                                       'pr_page'    => $redirid,
-                                       'pr_type'    => 'pr_type',
-                                       'pr_level'   => 'pr_level',
+                                       'pr_page' => $redirid,
+                                       'pr_type' => 'pr_type',
+                                       'pr_level' => 'pr_level',
                                        'pr_cascade' => 'pr_cascade',
-                                       'pr_user'    => 'pr_user',
-                                       'pr_expiry'  => 'pr_expiry'
+                                       'pr_user' => 'pr_user',
+                                       'pr_expiry' => 'pr_expiry'
                                ),
                                array( 'pr_page' => $pageid ),
                                __METHOD__,
@@ -3831,7 +3841,7 @@ class Title {
                $dbw->update( 'page',
                        /* SET */ array(
                                'page_namespace' => $nt->getNamespace(),
-                               'page_title'     => $nt->getDBkey(),
+                               'page_title' => $nt->getDBkey(),
                        ),
                        /* WHERE */ array( 'page_id' => $oldid ),
                        __METHOD__
@@ -3861,10 +3871,10 @@ class Title {
                        $newid = $redirectArticle->insertOn( $dbw );
                        if ( $newid ) { // sanity
                                $redirectRevision = new Revision( array(
-                                       'title'   => $this, // for determining the default content model
-                                       'page'    => $newid,
+                                       'title' => $this, // for determining the default content model
+                                       'page' => $newid,
                                        'comment' => $comment,
-                                       'content'    => $redirectContent ) );
+                                       'content' => $redirectContent ) );
                                $redirectRevision->insertOn( $dbw );
                                $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
 
@@ -3966,7 +3976,9 @@ class Title {
 
                # Is it a redirect?
                $fields = array( 'page_is_redirect', 'page_latest', 'page_id' );
-               if ( $wgContentHandlerUseDB ) $fields[] = 'page_content_model';
+               if ( $wgContentHandlerUseDB ) {
+                       $fields[] = 'page_content_model';
+               }
 
                $row = $dbw->selectRow( 'page',
                        $fields,
@@ -4020,7 +4032,7 @@ class Title {
                }
                # Get the article text
                $rev = Revision::newFromTitle( $nt, false, Revision::READ_LATEST );
-               if( !is_object( $rev ) ) {
+               if ( !is_object( $rev ) ) {
                        return false;
                }
                $content = $rev->getContent();
@@ -4322,7 +4334,7 @@ class Title {
                // No DB query needed if $old and $new are the same or successive revisions:
                if ( $old->getId() === $new->getId() ) {
                        return ( $old_cmp === '>' && $new_cmp === '<' ) ? 0 : 1;
-               } else if ( $old->getId() === $new->getParentId() ) {
+               } elseif ( $old->getId() === $new->getParentId() ) {
                        if ( $old_cmp === '>' || $new_cmp === '<' ) {
                                return ( $old_cmp === '>' && $new_cmp === '<' ) ? 0 : 1;
                        }
index 9c5ebcd..dcd33bc 100644 (file)
@@ -1060,7 +1060,7 @@ abstract class ContentHandler {
                                        if ( isset( $handler[1] ) ) {
                                                $info .= '::' . $handler[1];
                                        }
-                               } else if ( is_object( $handler ) ) {
+                               } elseif ( is_object( $handler ) ) {
                                        $info = get_class( $handler[0] );
                                        $info .= '::on' . $event;
                                } else {
index 0789e1b..80341b0 100644 (file)
@@ -52,9 +52,9 @@ class DatabaseSqlite extends DatabaseBase {
                $this->mName = $dbName;
                parent::__construct( $server, $user, $password, $dbName, $flags );
                // parent doesn't open when $user is false, but we can work with $dbName
-               if( $dbName ) {
+               if ( $dbName ) {
                        global $wgSharedDB;
-                       if( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) {
+                       if ( $this->open( $server, $user, $password, $dbName ) && $wgSharedDB ) {
                                $this->attachDatabase( $wgSharedDB );
                        }
                }
@@ -471,7 +471,7 @@ class DatabaseSqlite extends DatabaseBase {
         */
        function makeSelectOptions( $options ) {
                foreach ( $options as $k => $v ) {
-                       if ( is_numeric( $k ) && ($v == 'FOR UPDATE' || $v == 'LOCK IN SHARE MODE') ) {
+                       if ( is_numeric( $k ) && ( $v == 'FOR UPDATE' || $v == 'LOCK IN SHARE MODE' ) ) {
                                $options[$k] = '';
                        }
                }
@@ -542,7 +542,9 @@ class DatabaseSqlite extends DatabaseBase {
         * @return bool|ResultWrapper
         */
        function replace( $table, $uniqueIndexes, $rows, $fname = 'DatabaseSqlite::replace' ) {
-               if ( !count( $rows ) ) return true;
+               if ( !count( $rows ) ) {
+                       return true;
+               }
 
                # SQLite can't handle multi-row replaces, so divide up into multiple single-row queries
                if ( isset( $rows[0] ) && is_array( $rows[0] ) ) {
@@ -707,7 +709,7 @@ class DatabaseSqlite extends DatabaseBase {
        function addQuotes( $s ) {
                if ( $s instanceof Blob ) {
                        return "x'" . bin2hex( $s->fetch() ) . "'";
-               } else if ( strpos( $s, "\0" ) !== false ) {
+               } elseif ( strpos( $s, "\0" ) !== false ) {
                        // SQLite doesn't support \0 in strings, so use the hex representation as a workaround.
                        // This is a known limitation of SQLite's mprintf function which PDO should work around,
                        // but doesn't. I have reported this to php.net as bug #63419:
@@ -848,11 +850,11 @@ class DatabaseSqlite extends DatabaseBase {
 
                $endArray = array();
 
-               foreach( $result as $table ) {
+               foreach ( $result as $table ) {
                        $vars = get_object_vars( $table );
                        $table = array_pop( $vars );
 
-                       if( !$prefix || strpos( $table, $prefix ) === 0 ) {
+                       if ( !$prefix || strpos( $table, $prefix ) === 0 ) {
                                if ( strpos( $table, 'sqlite_' ) !== 0 ) {
                                        $endArray[] = $table;
                                }
index a69862d..8ee2b82 100644 (file)
@@ -365,8 +365,9 @@ class DifferenceEngine extends ContextSource {
 
                if ( $this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
                        $deleted = true; // new revisions text is hidden
-                       if ( $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED ) )
+                       if ( $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED ) ) {
                                $suppressed = true; // also suppressed
+                       }
                }
 
                # If the diff cannot be shown due to a deleted revision, then output
@@ -428,11 +429,11 @@ class DifferenceEngine extends ContextSource {
                                        $change = RecentChange::newFromConds(
                                                array(
                                                // Redundant user,timestamp condition so we can use the existing index
-                                                       'rc_user_text'  => $this->mNewRev->getRawUserText(),
-                                                       'rc_timestamp'  => $db->timestamp( $this->mNewRev->getTimestamp() ),
+                                                       'rc_user_text' => $this->mNewRev->getRawUserText(),
+                                                       'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ),
                                                        'rc_this_oldid' => $this->mNewid,
                                                        'rc_last_oldid' => $this->mOldid,
-                                                       'rc_patrolled'  => 0
+                                                       'rc_patrolled' => 0
                                                ),
                                                __METHOD__
                                        );
@@ -513,9 +514,9 @@ class DifferenceEngine extends ContextSource {
                                        $txt = $po ? $po->getText() : '';
                                        $out->addHTML( $txt );
                                }
-                       } elseif( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+                       } elseif ( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // Handled by extension
-                       } elseif( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+                       } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // NOTE: deprecated hook, B/C only
                                // Handled by extension
                        } else {
@@ -544,7 +545,7 @@ class DifferenceEngine extends ContextSource {
                                                # Show categories etc.
                                                $out->addParserOutputNoText( $parserOutput );
                                        }
-                               } else if ( $parserOutput ) {
+                               } elseif ( $parserOutput ) {
                                        $out->addParserOutput( $parserOutput );
                                }
                        }
@@ -861,7 +862,9 @@ class DifferenceEngine extends ContextSource {
        }
 
        function localiseLineNumbersCb( $matches ) {
-               if ( $matches[1] === '1' && $this->mReducedLineNumbers ) return '';
+               if ( $matches[1] === '1' && $this->mReducedLineNumbers ) {
+                       return '';
+               }
                return $this->msg( 'lineno' )->numParams( $matches[1] )->escaped();
        }
 
index f525319..371306f 100644 (file)
@@ -157,7 +157,7 @@ abstract class DatabaseUpdater {
         */
        public static function newForDB( &$db, $shared = false, $maintenance = null ) {
                $type = $db->getType();
-               if( in_array( $type, Installer::getDBTypes() ) ) {
+               if ( in_array( $type, Installer::getDBTypes() ) ) {
                        $class = ucfirst( $type ) . 'Updater';
                        return new $class( $db, $shared, $maintenance );
                } else {
@@ -184,7 +184,7 @@ abstract class DatabaseUpdater {
                        return;
                }
                global $wgCommandLineMode;
-               if( !$wgCommandLineMode ) {
+               if ( !$wgCommandLineMode ) {
                        $str = htmlspecialchars( $str );
                }
                echo $str;
@@ -357,7 +357,7 @@ abstract class DatabaseUpdater {
                $updates = $this->updatesSkipped;
                $this->updatesSkipped = array();
 
-               foreach( $updates as $funcList ) {
+               foreach ( $updates as $funcList ) {
                        $func = $funcList[0];
                        $arg = $funcList[1];
                        $origParams = $funcList[2];
@@ -400,7 +400,7 @@ abstract class DatabaseUpdater {
 
                $this->setAppliedUpdates( $wgVersion, $this->updates );
 
-               if( $this->fileHandle ) {
+               if ( $this->fileHandle ) {
                        $this->skipSchema = false;
                        $this->writeSchemaUpdateFile();
                        $this->setAppliedUpdates( "$wgVersion-schema", $this->updatesSkipped );
@@ -422,14 +422,14 @@ abstract class DatabaseUpdater {
                foreach ( $updates as $params ) {
                        $origParams = $params;
                        $func = array_shift( $params );
-                       if( !is_array( $func ) && method_exists( $this, $func ) ) {
+                       if ( !is_array( $func ) && method_exists( $this, $func ) ) {
                                $func = array( $this, $func );
                        } elseif ( $passSelf ) {
                                array_unshift( $params, $this );
                        }
                        $ret = call_user_func_array( $func, $params );
                        flush();
-                       if( $ret !== false ) {
+                       if ( $ret !== false ) {
                                $updatesDone[] = $origParams;
                        } else {
                                $updatesSkipped[] = array( $func, $params, $origParams );
@@ -445,7 +445,7 @@ abstract class DatabaseUpdater {
         */
        protected function setAppliedUpdates( $version, $updates = array() ) {
                $this->db->clearFlag( DBO_DDLMODE );
-               if( !$this->canUseNewUpdatelog() ) {
+               if ( !$this->canUseNewUpdatelog() ) {
                        return;
                }
                $key = "updatelist-$version-" . time();
@@ -483,7 +483,7 @@ abstract class DatabaseUpdater {
        public function insertUpdateRow( $key, $val = null ) {
                $this->db->clearFlag( DBO_DDLMODE );
                $values = array( 'ul_key' => $key );
-               if( $val && $this->canUseNewUpdatelog() ) {
+               if ( $val && $this->canUseNewUpdatelog() ) {
                        $values['ul_value'] = $val;
                }
                $this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' );
@@ -600,7 +600,7 @@ abstract class DatabaseUpdater {
         */
        public function appendLine( $line ) {
                $line = rtrim( $line ) . ";\n";
-               if( fwrite( $this->fileHandle, $line ) === false ) {
+               if ( fwrite( $this->fileHandle, $line ) === false ) {
                        throw new MWException( "trouble writing file" );
                }
                return false;
@@ -628,7 +628,7 @@ abstract class DatabaseUpdater {
                if ( !$isFullPath ) {
                        $path = $this->db->patchPath( $path );
                }
-               if( $this->fileHandle !== null ) {
+               if ( $this->fileHandle !== null ) {
                        $this->copyFile( $path );
                } else {
                        $this->db->sourceFile( $path );
@@ -698,7 +698,7 @@ abstract class DatabaseUpdater {
 
                if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
                        $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
-               } else if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
+               } elseif ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
                        $this->output( "...index $index already set on $table table.\n" );
                } else {
                        return $this->applyPatch( $patch, $fullpath, "Adding index $index to table $table" );
@@ -844,7 +844,7 @@ abstract class DatabaseUpdater {
                        $this->output( "...$table table does not exist, skipping modify field patch.\n" );
                } elseif ( !$this->db->fieldExists( $table, $field, __METHOD__ ) ) {
                        $this->output( "...$field field does not exist in $table table, skipping modify field patch.\n" );
-               } elseif( $this->updateRowExists( $updateKey ) ) {
+               } elseif ( $this->updateRowExists( $updateKey ) ) {
                        $this->output( "...$field in table $table already modified by patch $patch.\n" );
                } else {
                        $this->insertUpdateRow( $updateKey );
@@ -978,7 +978,7 @@ abstract class DatabaseUpdater {
         * Migrates user options from the user table blob to user_properties
         */
        protected function doMigrateUserOptions() {
-               if( $this->db->tableExists( 'user_properties' ) ) {
+               if ( $this->db->tableExists( 'user_properties' ) ) {
                        $cl = $this->maintenance->runChild( 'ConvertUserOptions', 'convertUserOptions.php' );
                        $cl->execute();
                        $this->output( "done.\n" );
index 6743619..dd613a7 100644 (file)
@@ -289,7 +289,7 @@ class ResourceLoader {
 
                // Add the testrunner (which configures QUnit) to the dependencies.
                // Since it must be ready before any of the test suites are executed.
-               foreach( $testModules['qunit'] as &$module ) {
+               foreach ( $testModules['qunit'] as &$module ) {
                        // Make sure all test modules are top-loading so that when QUnit starts
                        // on document-ready, it will run once and finish. If some tests arrive
                        // later (possibly after QUnit has already finished) they will be ignored.
@@ -297,7 +297,7 @@ class ResourceLoader {
                        $module['dependencies'][] = 'mediawiki.tests.qunit.testrunner';
                }
 
-               foreach( $testModules as $id => $names ) {
+               foreach ( $testModules as $id => $names ) {
                        // Register test modules
                        $this->register( $testModules[$id] );
 
@@ -914,7 +914,7 @@ class ResourceLoader {
 
                                        if ( $media === '' || $media == 'all' ) {
                                                $out[] = $style;
-                                       } else if ( is_string( $media ) ) {
+                                       } elseif ( is_string( $media ) ) {
                                                $out[] = "@media $media {\n" . str_replace( "\n", "\n\t", "\t" . $style ) . "}";
                                        }
                                        // else: skip
index e3dc488..9163d69 100644 (file)
@@ -40,17 +40,17 @@ class BackupDumper {
        var $reportingInterval = 100;
        var $reporting = true;
        var $pageCount = 0;
-       var $revCount  = 0;
-       var $server    = null; // use default
-       var $pages     = null; // all pages
+       var $revCount = 0;
+       var $server = null; // use default
+       var $pages = null; // all pages
        var $skipHeader = false; // don't output <mediawiki> and <siteinfo>
        var $skipFooter = false; // don't output </mediawiki>
-       var $startId    = 0;
-       var $endId      = 0;
+       var $startId = 0;
+       var $endId = 0;
        var $revStartId = 0;
-       var $revEndId   = 0;
-       var $sink       = null; // Output filters
-       var $stubText   = false; // include rev_text_id instead of text; for 2-pass dump
+       var $revEndId = 0;
+       var $sink = null; // Output filters
+       var $stubText = false; // include rev_text_id instead of text; for 2-pass dump
        var $dumpUploads = false;
        var $dumpUploadFileContents = false;
        var $lastTime = 0;
@@ -202,8 +202,9 @@ class BackupDumper {
        function dump( $history, $text = WikiExporter::TEXT ) {
                # Notice messages will foul up your XML output even if they're
                # relatively harmless.
-               if ( ini_get( 'display_errors' ) )
+               if ( ini_get( 'display_errors' ) ) {
                        ini_set( 'display_errors', 'stderr' );
+               }
 
                $this->initProgress( $history );
 
@@ -215,8 +216,9 @@ class BackupDumper {
                $wrapper = new ExportProgressFilter( $this->sink, $this );
                $exporter->setOutputSink( $wrapper );
 
-               if ( !$this->skipHeader )
+               if ( !$this->skipHeader ) {
                        $exporter->openStream();
+               }
                # Log item dumps: all or by range
                if ( $history & WikiExporter::LOGS ) {
                        if ( $this->startId || $this->endId ) {
@@ -225,7 +227,7 @@ class BackupDumper {
                                $exporter->allLogs();
                        }
                # Page dumps: all or by page ID range
-               } else if ( is_null( $this->pages ) ) {
+               } elseif ( is_null( $this->pages ) ) {
                        if ( $this->startId || $this->endId ) {
                                $exporter->pagesByRange( $this->startId, $this->endId );
                        } elseif ( $this->revStartId || $this->revEndId ) {
@@ -238,8 +240,9 @@ class BackupDumper {
                        $exporter->pagesByName( $this->pages );
                }
 
-               if ( !$this->skipFooter )
+               if ( !$this->skipFooter ) {
                        $exporter->closeStream();
+               }
 
                $this->report( true );
        }
index 81fbbb3..94a1876 100644 (file)
@@ -38,7 +38,7 @@ class CreateAndPromote extends Maintenance {
                parent::__construct();
                $this->mDescription = "Create a new user account and/or grant it additional rights";
                $this->addOption( "force", "If acccount exists already, just grant it rights or change password." );
-               foreach( self::$permitRoles as $role ) {
+               foreach ( self::$permitRoles as $role ) {
                        $this->addOption( $role, "Add the account to the {$role} group" );
                }
                $this->addArg( "username", "Username of new user" );
@@ -60,10 +60,10 @@ class CreateAndPromote extends Maintenance {
 
                if ( $exists && !$force ) {
                        $this->error( "Account exists. Perhaps you want the --force option?", true );
-               } else if ( !$exists && !$password ) {
+               } elseif ( !$exists && !$password ) {
                        $this->error( "Argument <password> required!", false );
                        $this->maybeHelp( true );
-               } else if ( $exists ) {
+               } elseif ( $exists ) {
                        $inGroups = $user->getGroups();
                }
 
@@ -72,7 +72,7 @@ class CreateAndPromote extends Maintenance {
                if ( $exists && !$password && count( $promotions ) === 0 ) {
                        $this->output( "Account exists and nothing to do.\n" );
                        return;
-               } else if ( count( $promotions ) !== 0 ) {
+               } elseif ( count( $promotions ) !== 0 ) {
                        $promoText = "User:{$username} into " . implode( ', ', $promotions ) . "...\n";
                        if ( $exists ) {
                                $this->output( wfWikiID() . ": Promoting $promoText" );
index dcd9b9b..9fbc0bc 100644 (file)
@@ -154,7 +154,7 @@ class languages {
                        if ( isset( $this->mGeneralMessages['required'][$key] ) ) {
                                $this->mMessages[$code]['required'][$key] = $value;
                                $this->mMessages[$code]['translated'][$key] = $value;
-                       } else if ( isset( $this->mGeneralMessages['optional'][$key] ) ) {
+                       } elseif ( isset( $this->mGeneralMessages['optional'][$key] ) ) {
                                $this->mMessages[$code]['optional'][$key] = $value;
                                $this->mMessages[$code]['translated'][$key] = $value;
                        } else {
@@ -184,7 +184,7 @@ class languages {
                foreach ( $this->mGeneralMessages['all'] as $key => $value ) {
                        if ( in_array( $key, $this->mIgnoredMessages ) ) {
                                $this->mGeneralMessages['ignored'][$key] = $value;
-                       } else if ( in_array( $key, $this->mOptionalMessages ) ) {
+                       } elseif ( in_array( $key, $this->mOptionalMessages ) ) {
                                $this->mGeneralMessages['optional'][$key] = $value;
                                $this->mGeneralMessages['translatable'][$key] = $value;
                        } else {
@@ -466,11 +466,11 @@ class languages {
                        '[POP]' => "\xE2\x80\xAC",
                        '[LRO]' => "\xE2\x80\xAD",
                        '[RLO]' => "\xE2\x80\xAB",
-                       '[ZWSP]'=> "\xE2\x80\x8B",
-                       '[NBSP]'=> "\xC2\xA0",
-                       '[WJ]'  => "\xE2\x81\xA0",
+                       '[ZWSP]' => "\xE2\x80\x8B",
+                       '[NBSP]' => "\xC2\xA0",
+                       '[WJ]' => "\xE2\x81\xA0",
                        '[BOM]' => "\xEF\xBB\xBF",
-                       '[FFFD]'=> "\xEF\xBF\xBD",
+                       '[FFFD]' => "\xEF\xBF\xBD",
                );
                $wrongRegExp = '/(' . implode( '|', array_values( $wrongChars ) ) . ')/sDu';
                $wrongCharsMessages = array();
@@ -500,8 +500,8 @@ class languages {
                foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
                        $matches = array();
                        preg_match_all( "/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu", $value, $matches );
-                       for ($i = 0; $i < count($matches[0]); $i++ ) {
-                               if ( preg_match( "/.*project.*/isDu",  $matches[1][$i] ) ) {
+                       for ( $i = 0; $i < count( $matches[0] ); $i++ ) {
+                               if ( preg_match( "/.*project.*/isDu", $matches[1][$i] ) ) {
                                        $messages[$key][] = $matches[0][$i];
                                }
                        }
@@ -563,7 +563,9 @@ class languages {
                $this->loadFile( 'en' );
                $this->loadFile( $code );
                $namespacesDiff = array_diff_key( $this->mNamespaceNames['en'], $this->mNamespaceNames[$code] );
-               if ( isset( $namespacesDiff[NS_MAIN] ) ) unset( $namespacesDiff[NS_MAIN] );
+               if ( isset( $namespacesDiff[NS_MAIN] ) ) {
+                       unset( $namespacesDiff[NS_MAIN] );
+               }
                return $namespacesDiff;
        }
 
@@ -579,7 +581,7 @@ class languages {
                $namespaces = array();
 
                # Check default namespace name
-               if( isset( $this->mNamespaceNames[$code][NS_PROJECT_TALK] ) ) {
+               if ( isset( $this->mNamespaceNames[$code][NS_PROJECT_TALK] ) ) {
                        $default = $this->mNamespaceNames[$code][NS_PROJECT_TALK];
                        if ( strpos( $default, '$1' ) === false ) {
                                $namespaces[$default] = 'default';
@@ -587,7 +589,7 @@ class languages {
                }
 
                # Check namespace aliases
-               foreach( $this->mNamespaceAliases[$code] as $key => $value ) {
+               foreach ( $this->mNamespaceAliases[$code] as $key => $value ) {
                        if ( $value == NS_PROJECT_TALK && strpos( $key, '$1' ) === false ) {
                                $namespaces[$key] = '';
                        }
@@ -758,9 +760,9 @@ class extensionLanguages extends languages {
         * @param $code string The language code.
         */
        protected function loadFile( $code ) {
-               if( !isset( $this->mRawMessages[$code] ) ) {
+               if ( !isset( $this->mRawMessages[$code] ) ) {
                        $this->mRawMessages[$code] = $this->mMessageGroup->load( $code );
-                       if( empty( $this->mRawMessages[$code] ) ) {
+                       if ( empty( $this->mRawMessages[$code] ) ) {
                                $this->mRawMessages[$code] = array();
                        }
                }
index 1572869..1491421 100644 (file)
@@ -48,7 +48,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance {
                $db = $this->getDB( DB_MASTER );
                if ( !$db->tableExists( 'revision' ) ) {
                        $this->error( "revision table does not exist", true );
-               } else if ( !$db->fieldExists( 'revision', 'rev_len', __METHOD__ ) ) {
+               } elseif ( !$db->fieldExists( 'revision', 'rev_len', __METHOD__ ) ) {
                        $this->output( "rev_len column does not exist\n\n", true );
                        return false;
                }
index 113eef4..dfe905e 100644 (file)
@@ -48,7 +48,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                        $this->error( "revision table does not exist", true );
                } elseif ( !$db->tableExists( 'archive' ) ) {
                        $this->error( "archive table does not exist", true );
-               } else if ( !$db->fieldExists( 'revision', 'rev_sha1', __METHOD__ ) ) {
+               } elseif ( !$db->fieldExists( 'revision', 'rev_sha1', __METHOD__ ) ) {
                        $this->output( "rev_sha1 column does not exist\n\n", true );
                        return false;
                }
@@ -189,9 +189,9 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                                array( 'ar_sha1' => Revision::base36Sha1( $text ) ),
                                array(
                                        'ar_namespace' => $row->ar_namespace,
-                                       'ar_title'     => $row->ar_title,
+                                       'ar_title' => $row->ar_title,
                                        'ar_timestamp' => $row->ar_timestamp,
-                                       'ar_len'       => $row->ar_len // extra sanity
+                                       'ar_len' => $row->ar_len // extra sanity
                                ),
                                __METHOD__
                        );
index f69a9b0..e225ebb 100644 (file)
@@ -83,7 +83,7 @@ class UpdateMediaWiki extends Maintenance {
        function execute() {
                global $wgVersion, $wgTitle, $wgLang, $wgAllowSchemaUpdates;
 
-               if( !$wgAllowSchemaUpdates && !( $this->hasOption( 'force' ) || $this->hasOption( 'schema' ) || $this->hasOption( 'noschema' ) ) ) {
+               if ( !$wgAllowSchemaUpdates && !( $this->hasOption( 'force' ) || $this->hasOption( 'schema' ) || $this->hasOption( 'noschema' ) ) ) {
                        $this->error( "Do not run update.php on this wiki. If you're seeing this you should\n"
                                . "probably ask for some help in performing your schema updates or use\n"
                                . "the --noschema and --schema options to get an SQL file for someone\n"
@@ -92,12 +92,12 @@ class UpdateMediaWiki extends Maintenance {
                }
 
                $this->fileHandle = null;
-               if( substr( $this->getOption( 'schema' ), 0, 2 ) === "--" ) {
+               if ( substr( $this->getOption( 'schema' ), 0, 2 ) === "--" ) {
                        $this->error( "The --schema option requires a file as an argument.\n", true );
-               } else if( $this->hasOption( 'schema' ) ) {
+               } elseif ( $this->hasOption( 'schema' ) ) {
                        $file = $this->getOption( 'schema' );
                        $this->fileHandle = fopen( $file, "w" );
-                       if( $this->fileHandle === false ) {
+                       if ( $this->fileHandle === false ) {
                                $err = error_get_last();
                                $this->error( "Problem opening the schema file for writing: $file\n\t{$err['message']}", true );
                        }
@@ -122,7 +122,7 @@ class UpdateMediaWiki extends Maintenance {
                $db = wfGetDB( DB_MASTER );
 
                $this->output( "Going to run database updates for " . wfWikiID() . "\n" );
-               if( $db->getType() === 'sqlite' ) {
+               if ( $db->getType() === 'sqlite' ) {
                        $this->output( "Using SQLite file: '{$db->mDatabaseFile}'\n" );
                }
                $this->output( "Depending on the size of your database this may take a while!\n" );
@@ -135,13 +135,13 @@ class UpdateMediaWiki extends Maintenance {
                $shared = $this->hasOption( 'doshared' );
 
                $updates = array( 'core', 'extensions' );
-               if( !$this->hasOption('schema') ) {
-                       if( $this->hasOption('noschema') ) {
+               if ( !$this->hasOption( 'schema' ) ) {
+                       if ( $this->hasOption( 'noschema' ) ) {
                                $updates[] = 'noschema';
                        }
                        $updates[] = 'stats';
 
-                       if( !$this->hasOption('nopurge') ) {
+                       if ( !$this->hasOption( 'nopurge' ) ) {
                                $updates[] = 'purge';
                        }
                }
@@ -149,7 +149,7 @@ class UpdateMediaWiki extends Maintenance {
                $updater = DatabaseUpdater::newForDb( $db, $shared, $this );
                $updater->doUpdates( $updates );
 
-               foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
+               foreach ( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
                        $child = $this->runChild( $maint );
 
                        // LoggedUpdateMaintenance is checking the updatelog itself
@@ -166,7 +166,7 @@ class UpdateMediaWiki extends Maintenance {
                        }
                }
 
-               if( !$this->hasOption('nopurge') ) {
+               if ( !$this->hasOption( 'nopurge' ) ) {
                        $updater->purgeCache();
                }