r84907 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84906‎ | r84907 | r84908 >
Date:16:11, 28 March 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
fix for call to uninitialized parser
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -12,7 +12,7 @@
1313 static function setGlobalJSVariables( &$vars ) {
1414 global $sfgAutocompleteValues, $sfgAutocompleteOnAllChars;
1515 global $sfgInitJSFunctions, $sfgValidationJSFunctions;
16 - global $sfgShowOnSelect, $wgParser;
 16+ global $sfgShowOnSelect, $wgParser, $wgUser;
1717
1818 $vars['sfgRemoveText'] = wfMsg( 'sf_formedit_remove' );
1919 $vars['sfgAutocompleteOnAllChars'] = $sfgAutocompleteOnAllChars;
@@ -29,7 +29,17 @@
3030 $vars['sfgBadNumberErrorStr'] = wfMsg( 'sf_bad_number_error' );
3131 $vars['sfgBadIntegerErrorStr'] = wfMsg( 'sf_bad_integer_error' );
3232 $vars['sfgBadDateErrorStr'] = wfMsg( 'sf_bad_date_error' );
33 - $vars['sfgAnonEditWarning'] = StringUtils::delimiterReplace( '<', '>', '', $wgParser->recursiveTagParse( wfMsg( 'anoneditwarning' ) ) );
 33+
 34+ // $wgParser might not be initialized, e.g. on Special pages
 35+ if ( $wgParser->mOptions == null ) {
 36+ $parser = new Parser();
 37+ $msg = $parser -> parse (wfMsg( 'anoneditwarning' ), new Title(), ParserOptions::newFromUser( $wgUser ) ) -> getText();
 38+ } else {
 39+ $msg = $wgParser->recursiveTagParse( wfMsg( 'anoneditwarning' ) );
 40+ }
 41+
 42+ $vars['sfgAnonEditWarning'] = StringUtils::delimiterReplace( '<', '>', '', $msg );
 43+
3444 return true;
3545 }
3646