Emit a warning message if a single page has multiple conflicting {{DEFAULTSORT:}...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 2 Nov 2008 14:21:04 +0000 (14:21 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Sun, 2 Nov 2008 14:21:04 +0000 (14:21 +0000)
(Also, replace wfMsg() with wfMsgForContent() for the unknown_extension_tag message.)

RELEASE-NOTES
includes/parser/CoreParserFunctions.php
includes/parser/Parser.php
languages/messages/MessagesEn.php

index 7ffe694..d1e6f02 100644 (file)
@@ -302,6 +302,8 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 16160) Suggestions box should be resized from left for RTL wikis
 * (bug 11533) Fixed insane slowdown when in read-only mode for long periods
   of time with CACHE_NONE (default objectcache table configuration).
+* Trying to set two different default category sort keys for one page now produces
+  a warning
 
 === API changes in 1.14 ===
 
index 6465cc1..6311b61 100644 (file)
@@ -330,9 +330,18 @@ class CoreParserFunctions {
 
        public static function defaultsort( $parser, $text ) {
                $text = trim( $text );
-               if( strlen( $text ) > 0 )
-                       $parser->setDefaultSort( $text );
-               return '';
+               if( strlen( $text ) == 0 )
+                       return '';
+               $old = $parser->getCustomDefaultSort();
+               $parser->setDefaultSort( $text );
+               if( $old === false || $old == $text )
+                       return '';
+               else
+                       return( '<span class="error">' .
+                               wfMsgForContent( 'duplicate_defaultsort',
+                                                htmlspecialchars( $old ),
+                                                htmlspecialchars( $text ) ) .
+                               '</span>' );
        }
 
        public static function filepath( $parser, $name='', $option='' ) {
@@ -367,7 +376,7 @@ class CoreParserFunctions {
                $stripList = $parser->getStripList();
                if ( !in_array( $tagName, $stripList ) ) {
                        return '<span class="error">' .
-                               wfMsg( 'unknown_extension_tag', $tagName ) .
+                               wfMsgForContent( 'unknown_extension_tag', $tagName ) .
                                '</span>';
                }
 
index 561283a..1a84efa 100644 (file)
@@ -4713,6 +4713,16 @@ class Parser
                }
        }
 
+       /**
+        * Accessor for $mDefaultSort
+        * Unlike getDefaultSort(), will return false if none is set
+        *
+        * @return string or false
+        */
+       public function getCustomDefaultSort() {
+               return $this->mDefaultSort;
+       }
+
        /**
         * Try to guess the section anchor name based on a wikitext fragment
         * presumably extracted from a heading, for example "Header" from
index 50b0588..56e63eb 100644 (file)
@@ -3661,6 +3661,7 @@ You can also [[Special:Watchlist/edit|use the standard editor]].',
 
 # Core parser functions
 'unknown_extension_tag' => 'Unknown extension tag "$1"',
+'duplicate_defaultsort' => 'Warning: Default sort key "$2" overrides earlier default sort key "$1".',
 
 # Special:Version
 'version'                          => 'Version', # Not used as normal message but as header for the special page itself