Made loadFromFileCache() always disable $wgOut regardless of whether compression...
[lhc/web/wiklou.git] / includes / parser / CoreParserFunctions.php
index 54800bd..f9ae237 100644 (file)
@@ -97,9 +97,8 @@ class CoreParserFunctions {
        static function intFunction( $parser, $part1 = '' /*, ... */ ) {
                if ( strval( $part1 ) !== '' ) {
                        $args = array_slice( func_get_args(), 2 );
-                       $message = wfMessage( $part1, $args )->inLanguage( $parser->getOptions()->getUserLang() )->plain();
-                       $message = $parser->replaceVariables( $message ); // like MessageCache::transform()
-                       return $message;
+                       $message = wfMessage( $part1, $args )->inLanguage( $parser->getOptions()->getUserLangObj() )->plain();
+                       return array( $message, 'noparse' => false );
                } else {
                        return array( 'found' => false );
                }
@@ -278,7 +277,14 @@ class CoreParserFunctions {
         */
        static function gender( $parser, $username ) {
                wfProfileIn( __METHOD__ );
-               $forms = array_slice( func_get_args(), 2);
+               $forms = array_slice( func_get_args(), 2 );
+
+               // Some shortcuts to avoid loading user data unnecessarily
+               if ( count( $forms ) === 0 ) {
+                       return '';
+               } elseif ( count( $forms ) === 1 ) {
+                       return $forms[0];
+               }
 
                $username = trim( $username );
 
@@ -563,7 +569,11 @@ class CoreParserFunctions {
         *   to the link cache, so the local cache here should be unnecessary, but
         *   in fact calling getLength() repeatedly for the same $page does seem to
         *   run one query for each call?
+        * @todo Document parameters
+        *
         * @param $parser Parser
+        * @param $page String TODO DOCUMENT (Default: empty string)
+        * @param $raw TODO DOCUMENT (Default: null)
         */
        static function pagesize( $parser, $page = '', $raw = null ) {
                static $cache = array();
@@ -678,24 +688,27 @@ class CoreParserFunctions {
        /**
         * @param $parser Parser
         * @param $text String The sortkey to use
-        * @param $arg String Either "noreplace" or "noerror"
+        * @param $uarg String Either "noreplace" or "noerror" (in en)
         *   both suppress errors, and noreplace does nothing if
         *   a default sortkey already exists.
         * @return string
         */
-       public static function defaultsort( $parser, $text, $arg = '' ) {
+       public static function defaultsort( $parser, $text, $uarg = '' ) {
+               static $magicWords = null;
+               if ( is_null( $magicWords ) ) {
+                       $magicWords = new MagicWordArray( array( 'defaultsort_noerror', 'defaultsort_noreplace' ) );
+               }
+               $arg = $magicWords->matchStartToEnd( $uarg );
+
                $text = trim( $text );
-               $arg = trim( strtolower( $arg ) );
                if( strlen( $text ) == 0 )
                        return '';
                $old = $parser->getCustomDefaultSort();
-               if ( $old === false || $arg !== 'noreplace' ) {
+               if ( $old === false || $arg !== 'defaultsort_noreplace' ) {
                        $parser->setDefaultSort( $text );
                }
 
-               if( $old === false || $old == $text || $arg === 'noreplace'
-                       || $arg === 'noerror' )
-               {
+               if( $old === false || $old == $text || $arg ) {
                        return '';
                } else {
                        return( '<span class="error">' .