Emit a warning message if a single page has multiple conflicting {{DEFAULTSORT:}} keys.

(Also, replace wfMsg() with wfMsgForContent() for the unknown_extension_tag message.)
This commit is contained in:
Ilmari Karonen 2008-11-02 14:21:04 +00:00
parent 533cbdbdf8
commit a3fbf7fc49
4 changed files with 26 additions and 4 deletions

View 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 ===

View 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>';
}

View 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

View 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