r102972 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102971‎ | r102972 | r102973 >
Date:12:22, 14 November 2011
Author:catrope
Status:ok
Tags:
Comment:
(bug 17865) Fix double-parsed error messages in Cite. Modified patch by Brad Jorsch
Modified paths:
  • /trunk/extensions/Cite/Cite_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Cite/Cite_body.php
@@ -706,7 +706,7 @@
707707 'cite_references_link_one',
708708 $this->referencesKey( $key ),
709709 $this->refKey( $key, $val['count'] ),
710 - $this->error( 'cite_error_references_no_text', $key )
 710+ $this->error( 'cite_error_references_no_text', $key, 'noparse' )
711711 );
712712 }
713713
@@ -716,8 +716,7 @@
717717 $this->referencesKey( $val['key'] ),
718718 # $this->refKey( $val['key'], $val['count'] ),
719719 $this->refKey( $val['key'] ),
720 -
721 - ( $val['text'] != '' ? rtrim( $val['text'], "\n" ) . "\n" : $this->error( 'cite_error_references_no_text', $key ) )
 720+ ( $val['text'] != '' ? rtrim( $val['text'], "\n" ) . "\n" : $this->error( 'cite_error_references_no_text', $key, 'noparse' ) )
722721 );
723722 // Standalone named reference, I want to format this like an
724723 // anonymous reference because displaying "1. 1.1 Ref text" is
@@ -729,7 +728,7 @@
730729 $this->referencesKey( $key . "-" . $val['key'] ),
731730 # $this->refKey( $key, $val['count'] ),
732731 $this->refKey( $key, $val['key'] . "-" . $val['count'] ),
733 - ( $val['text'] != '' ? rtrim( $val['text'], "\n" ) . "\n" : $this->error( 'cite_error_references_no_text', $key ) )
 732+ ( $val['text'] != '' ? rtrim( $val['text'], "\n" ) . "\n" : $this->error( 'cite_error_references_no_text', $key, 'noparse' ) )
734733 );
735734 // Named references with >1 occurrences
736735 } else {
@@ -749,7 +748,7 @@
750749 return wfMsgForContentNoTrans( 'cite_references_link_many',
751750 $this->referencesKey( $key . "-" . $val['key'] ),
752751 $list,
753 - ( $val['text'] != '' ? rtrim( $val['text'], "\n" ) . "\n" : $this->error( 'cite_error_references_no_text', $key ) )
 752+ ( $val['text'] != '' ? rtrim( $val['text'], "\n" ) . "\n" : $this->error( 'cite_error_references_no_text', $key, 'noparse' ) )
754753 );
755754 }
756755 }
@@ -793,7 +792,7 @@
794793 return $this->mBacklinkLabels[$offset];
795794 } else {
796795 // Feed me!
797 - return $this->error( 'cite_error_references_no_backlink_label' );
 796+ return $this->error( 'cite_error_references_no_backlink_label', null, 'noparse' );
798797 }
799798 }
800799
@@ -823,7 +822,7 @@
824823 return $this->mLinkLabels[$group][$offset - 1];
825824 } else {
826825 // Feed me!
827 - return $this->error( 'cite_error_no_link_label_group', array( $group, $message ) );
 826+ return $this->error( 'cite_error_no_link_label_group', array( $group, $message ), 'noparse' );
828827 }
829828 }
830829
@@ -1117,18 +1116,20 @@
11181117 *
11191118 * @param string $key Message name for the error
11201119 * @param string $param Parameter to pass to the message
1121 - * @return string XHTML ready for output
 1120+ * @param string $parse Whether to parse the message ('parse') or not ('noparse')
 1121+ * @return string XHTML or wikitext ready for output
11221122 */
1123 - function error( $key, $param = null ) {
 1123+ function error( $key, $param = null, $parse = 'parse' ) {
11241124 # We rely on the fact that PHP is okay with passing unused argu-
11251125 # ments to functions. If $1 is not used in the message, wfMsg will
11261126 # just ignore the extra parameter.
1127 - return
1128 - $this->parse(
1129 - '<strong class="error">' .
1130 - wfMsgNoTrans( 'cite_error', wfMsgNoTrans( $key, $param ) ) .
1131 - '</strong>'
1132 - );
 1127+ $ret = '<strong class="error">' .
 1128+ wfMsgNoTrans( 'cite_error', wfMsgNoTrans( $key, $param ) ) .
 1129+ '</strong>';
 1130+ if ( $parse == 'parse' ) {
 1131+ $ret = $this->parse( $ret );
 1132+ }
 1133+ return $ret;
11331134 }
11341135
11351136 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102967Fixes bug #17865gwicke11:06, 14 November 2011

Status & tagging log