r96767 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96766‎ | r96767 | r96768 >
Date:02:20, 11 September 2011
Author:bawolff
Status:resolved (Comments)
Tags:
Comment:
(bug 16755) Add syntax to DEFAULTSORT - {{DEFAULTSORT:Foo|noerror}} and {{DEFAULTSORT:Bar|noreplace}}
to in both cases prevent the "A sortkey already was specified earlier in the page, yadda yadda" message and in the second case, also do not replace the sortkey
if one was already specified.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -57,6 +57,8 @@
5858 * (bug 30774) mediawiki.html: Add support for numbers and booleans in the
5959 attribute values and element contents.
6060 * Conversion script between Tifinagh and Latin for the Tachelhit language
 61+* (bug 16755) Add options 'noreplace' and 'noerror' to {{DEFAULTSORT:...}}
 62+ to stop it from replace an already existing default sort, and suppress error.
6163
6264 === Bug fixes in 1.19 ===
6365 * $wgUploadNavigationUrl should be used for file redlinks if
Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -677,23 +677,33 @@
678678
679679 /**
680680 * @param $parser Parser
681 - * @param $text
 681+ * @param $text String The sortkey to use
 682+ * @param $arg String Either "noreplace" or "noerror"
 683+ * both suppress errors, and noreplace does nothing if
 684+ * a default sortkey already exists.
682685 * @return string
683686 */
684 - public static function defaultsort( $parser, $text ) {
 687+ public static function defaultsort( $parser, $text, $arg = '' ) {
685688 $text = trim( $text );
 689+ $arg = trim( strtolower( $arg ) );
686690 if( strlen( $text ) == 0 )
687691 return '';
688692 $old = $parser->getCustomDefaultSort();
689 - $parser->setDefaultSort( $text );
690 - if( $old === false || $old == $text )
 693+ if ( $old === false || $arg !== 'noreplace' ) {
 694+ $parser->setDefaultSort( $text );
 695+ }
 696+
 697+ if( $old === false || $old == $text || $arg === 'noreplace'
 698+ || $arg === 'noerror' )
 699+ {
691700 return '';
692 - else
 701+ } else {
693702 return( '<span class="error">' .
694703 wfMsgForContent( 'duplicate-defaultsort',
695704 htmlspecialchars( $old ),
696705 htmlspecialchars( $text ) ) .
697706 '</span>' );
 707+ }
698708 }
699709
700710 // Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}}

Follow-up revisions

RevisionCommit summaryAuthorDate
r96809(follow-up r96767) Make {{DEFAULTSORT:..|noerror}} and noreplace i18n-izable....bawolff20:32, 11 September 2011

Comments

#Comment by Nikerabbit (talk | contribs)   10:09, 11 September 2011

shouldn't noreplace and noerror be i18ned?

#Comment by Bawolff (talk | contribs)   20:33, 11 September 2011

yep it should. Done in r96809

Status & tagging log