From: Ilmari Karonen Date: Sun, 2 Nov 2008 14:21:04 +0000 (+0000) Subject: Emit a warning message if a single page has multiple conflicting {{DEFAULTSORT:}... X-Git-Tag: 1.31.0-rc.0~44469 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=a3fbf7fc492b21ea6ee2f9df54513d564a5fdbd9;p=lhc%2Fweb%2Fwiklou.git Emit a warning message if a single page has multiple conflicting {{DEFAULTSORT:}} keys. (Also, replace wfMsg() with wfMsgForContent() for the unknown_extension_tag message.) --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7ffe694330..d1e6f02044 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 6465cc1ed2..6311b6142a 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -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( '' . + wfMsgForContent( 'duplicate_defaultsort', + htmlspecialchars( $old ), + htmlspecialchars( $text ) ) . + '' ); } public static function filepath( $parser, $name='', $option='' ) { @@ -367,7 +376,7 @@ class CoreParserFunctions { $stripList = $parser->getStripList(); if ( !in_array( $tagName, $stripList ) ) { return '' . - wfMsg( 'unknown_extension_tag', $tagName ) . + wfMsgForContent( 'unknown_extension_tag', $tagName ) . ''; } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 561283a6c1..1a84efa62b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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 diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 50b0588aa0..56e63eb574 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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