Merge "No spaces after (casts)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 4 Sep 2013 18:14:05 +0000 (18:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 4 Sep 2013 18:14:05 +0000 (18:14 +0000)
1  2 
includes/GlobalFunctions.php
includes/OutputPage.php
languages/Language.php

@@@ -2010,42 -2010,15 +2010,42 @@@ function wfCheckLimits( $deflimit = 50
   * @return String
   */
  function wfEscapeWikiText( $text ) {
 -      $text = strtr( "\n$text", array(
 -              '"' => '&#34;', '&' => '&#38;', "'" => '&#39;', '<' => '&#60;',
 -              '=' => '&#61;', '>' => '&#62;', '[' => '&#91;', ']' => '&#93;',
 -              '{' => '&#123;', '|' => '&#124;', '}' => '&#125;',
 -              "\n#" => "\n&#35;", "\n*" => "\n&#42;",
 -              "\n:" => "\n&#58;", "\n;" => "\n&#59;",
 -              '://' => '&#58;//', 'ISBN ' => 'ISBN&#32;', 'RFC ' => 'RFC&#32;',
 -      ) );
 -      return substr( $text, 1 );
 +      static $repl = null, $repl2 = null;
 +      if ( $repl === null ) {
 +              $repl = array(
 +                      '"' => '&#34;', '&' => '&#38;', "'" => '&#39;', '<' => '&#60;',
 +                      '=' => '&#61;', '>' => '&#62;', '[' => '&#91;', ']' => '&#93;',
 +                      '{' => '&#123;', '|' => '&#124;', '}' => '&#125;',
 +                      "\n#" => "\n&#35;", "\r#" => "\r&#35;",
 +                      "\n*" => "\n&#42;", "\r*" => "\r&#42;",
 +                      "\n:" => "\n&#58;", "\r:" => "\r&#58;",
 +                      "\n;" => "\n&#59;", "\r;" => "\r&#59;",
 +                      "\n " => "\n&#32;", "\r " => "\r&#32;",
 +                      '__' => '_&#95;', '://' => '&#58;//',
 +              );
 +
 +              // We have to catch everything "\s" matches in PCRE
 +              foreach ( array( 'ISBN', 'RFC', 'PMID' ) as $magic ) {
 +                      $repl["$magic "] = "$magic&#32;";
 +                      $repl["$magic\t"] = "$magic&#9;";
 +                      $repl["$magic\r"] = "$magic&#13;";
 +                      $repl["$magic\n"] = "$magic&#10;";
 +                      $repl["$magic\f"] = "$magic&#12;";
 +              }
 +
 +              // And handle protocols that don't use "://"
 +              global $wgUrlProtocols;
 +              $repl2 = array();
 +              foreach ( $wgUrlProtocols as $prot ) {
 +                      if ( substr( $prot, -1 ) === ':' ) {
 +                              $repl2[] = preg_quote( substr( $prot, 0, -1 ), '/' );
 +                      }
 +              }
 +              $repl2 = $repl2 ? '/\b(' . join( '|', $repl2 ) . '):/i' : '/^(?!)/';
 +      }
 +      $text = substr( strtr( "\n$text", $repl ), 1 );
 +      $text = preg_replace( $repl2, '$1&#58;', $text );
 +      return $text;
  }
  
  /**
@@@ -3183,9 -3156,9 +3183,9 @@@ function wfBaseConvert( $input, $source
                $sourceBase > 36 ||
                $destBase < 2 ||
                $destBase > 36 ||
-               $sourceBase != (int) $sourceBase ||
-               $destBase != (int) $destBase ||
-               $pad != (int) $pad ||
+               $sourceBase != (int)$sourceBase ||
+               $destBase != (int)$destBase ||
+               $pad != (int)$pad ||
                !preg_match( "/^[" . substr( '0123456789abcdefghijklmnopqrstuvwxyz', 0, $sourceBase ) . "]+$/i", $input )
        ) {
                return false;
                                $work += $digit;
  
                                if ( $workDigits || $work >= $destBase ) {
-                                       $workDigits[] = (int) ( $work / $destBase );
+                                       $workDigits[] = (int)( $work / $destBase );
                                }
                                $work %= $destBase;
                        }
diff --combined includes/OutputPage.php
@@@ -1534,7 -1534,7 +1534,7 @@@ class OutputPage extends ContextSource 
  
                $popts = $this->parserOptions();
                $oldTidy = $popts->setTidy( $tidy );
-               $popts->setInterfaceMessage( (bool) $interface );
+               $popts->setInterfaceMessage( (bool)$interface );
  
                $parserOutput = $wgParser->parse(
                        $text, $title, $popts,
@@@ -2432,6 -2432,14 +2432,6 @@@ $template
         * @param $options Options array to pass to Linker
         */
        public function addReturnTo( $title, $query = array(), $text = null, $options = array() ) {
 -              if ( in_array( 'http', $options ) ) {
 -                      $proto = PROTO_HTTP;
 -              } elseif ( in_array( 'https', $options ) ) {
 -                      $proto = PROTO_HTTPS;
 -              } else {
 -                      $proto = PROTO_RELATIVE;
 -              }
 -
                $link = $this->msg( 'returnto' )->rawParams(
                        Linker::link( $title, $text, array(), $query, $options ) )->escaped();
                $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
        protected function makeResourceLoaderLink( $modules, $only, $useESI = false, array $extraQuery = array(), $loadCall = false ) {
                global $wgResourceLoaderUseESI;
  
-               $modules = (array) $modules;
+               $modules = (array)$modules;
  
                if ( !count( $modules ) ) {
                        return '';
diff --combined languages/Language.php
@@@ -686,18 -686,7 +686,18 @@@ class Language 
                                }
                        }
  
 -                      $this->namespaceAliases = $aliases;
 +                      # Also add converted namespace names as aliases, to avoid confusion.
 +                      $convertedNames = array();
 +                      foreach ( $this->getVariants() as $variant ) {
 +                              if ( $variant === $this->mCode ) {
 +                                      continue;
 +                              }
 +                              foreach ( $this->getNamespaces() as $ns => $_ ) {
 +                                      $convertedNames[$this->getConverter()->convertNamespace( $ns, $variant )] = $ns;
 +                              }
 +                      }
 +
 +                      $this->namespaceAliases = $aliases + $convertedNames;
                }
                return $this->namespaceAliases;
        }
                $segments = array();
  
                foreach ( $intervals as $intervalName => $intervalValue ) {
 -                      // Messages: duration-centuries, duration-decades, duration-years, duration-days,
 -                      // duration-hours, duration-minutes, duration-seconds
 +                      // Messages: duration-seconds, duration-minutes, duration-hours, duration-days, duration-weeks,
 +                      // duration-years, duration-decades, duration-centuries, duration-millennia
                        $message = wfMessage( 'duration-' . $intervalName )->numParams( $intervalValue );
                        $segments[] = $message->inLanguage( $this )->escaped();
                }
                foreach ( $forms as $index => $form ) {
                        if ( preg_match( '/^\d+=/i', $form ) ) {
                                $pos = strpos( $form, '=' );
-                               if ( substr( $form, 0, $pos ) === (string) $count ) {
+                               if ( substr( $form, 0, $pos ) === (string)$count ) {
                                        return substr( $form, $pos + 1 );
                                }
                                unset( $forms[$index] );