r43077 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43076‎ | r43077 | r43078 >
Date:14:21, 2 November 2008
Author:vyznev
Status:old (Comments)
Tags:
Comment:
Emit a warning message if a single page has multiple conflicting {{DEFAULTSORT:}} keys.
(Also, replace wfMsg() with wfMsgForContent() for the unknown_extension_tag message.)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -4714,6 +4714,16 @@
47154715 }
47164716
47174717 /**
 4718+ * Accessor for $mDefaultSort
 4719+ * Unlike getDefaultSort(), will return false if none is set
 4720+ *
 4721+ * @return string or false
 4722+ */
 4723+ public function getCustomDefaultSort() {
 4724+ return $this->mDefaultSort;
 4725+ }
 4726+
 4727+ /**
47184728 * Try to guess the section anchor name based on a wikitext fragment
47194729 * presumably extracted from a heading, for example "Header" from
47204730 * "== Header ==".
Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -330,9 +330,18 @@
331331
332332 public static function defaultsort( $parser, $text ) {
333333 $text = trim( $text );
334 - if( strlen( $text ) > 0 )
335 - $parser->setDefaultSort( $text );
336 - return '';
 334+ if( strlen( $text ) == 0 )
 335+ return '';
 336+ $old = $parser->getCustomDefaultSort();
 337+ $parser->setDefaultSort( $text );
 338+ if( $old === false || $old == $text )
 339+ return '';
 340+ else
 341+ return( '<span class="error">' .
 342+ wfMsgForContent( 'duplicate_defaultsort',
 343+ htmlspecialchars( $old ),
 344+ htmlspecialchars( $text ) ) .
 345+ '</span>' );
337346 }
338347
339348 public static function filepath( $parser, $name='', $option='' ) {
@@ -367,7 +376,7 @@
368377 $stripList = $parser->getStripList();
369378 if ( !in_array( $tagName, $stripList ) ) {
370379 return '<span class="error">' .
371 - wfMsg( 'unknown_extension_tag', $tagName ) .
 380+ wfMsgForContent( 'unknown_extension_tag', $tagName ) .
372381 '</span>';
373382 }
374383
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3661,6 +3661,7 @@
36623662
36633663 # Core parser functions
36643664 'unknown_extension_tag' => 'Unknown extension tag "$1"',
 3665+'duplicate_defaultsort' => 'Warning: Default sort key "$2" overrides earlier default sort key "$1".',
36653666
36663667 # Special:Version
36673668 'version' => 'Version', # Not used as normal message but as header for the special page itself
Index: trunk/phase3/RELEASE-NOTES
@@ -302,6 +302,8 @@
303303 * (bug 16160) Suggestions box should be resized from left for RTL wikis
304304 * (bug 11533) Fixed insane slowdown when in read-only mode for long periods
305305 of time with CACHE_NONE (default objectcache table configuration).
 306+* Trying to set two different default category sort keys for one page now produces
 307+ a warning
306308
307309 === API changes in 1.14 ===
308310

Follow-up revisions

RevisionCommit summaryAuthorDate
r43090Fix for r43077:...raymond18:46, 2 November 2008
r43091Follow up on r43077siebrand19:18, 2 November 2008

Comments

#Comment by Raymond (talk | contribs)   17:06, 2 November 2008

Why wfMsgForContent? I want to read the error message in my user preference language.

#Comment by Raymond (talk | contribs)   18:53, 2 November 2008

Changed to wfMsg in r43090. Message renamed to 'duplicate-defaultsort' to stick with MediaWiki code standards.

Status & tagging log