r82928 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82927‎ | r82928 | r82929 >
Date:03:39, 28 February 2011
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Simplified form-parsing code, to work with latest MW 1.18; hopefully this still works with MW < 1.16
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -349,10 +349,9 @@
350350 // element, so that the wiki parser won't touch it - the parser will
351351 // remove the '<nowiki>' tags, leaving us with what we need.
352352 $form_def = "__NOEDITSECTION__" . strtr( $form_def, array( '{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>' ) );
353 - $old_strip_state = $wgParser->mStripState;
354 - $wgParser->mStripState = new StripState();
355 - $wgParser->mOptions = new ParserOptions();
356 - $wgParser->mOptions->initialiseFromUser( $wgUser );
 353+ if ( empty( $wgParser->mOptions ) ) {
 354+ $wgParser->mOptions = new ParserOptions();
 355+ }
357356
358357 // Get the form definition from the cache, if we're using caching and it's
359358 // there.
@@ -370,7 +369,6 @@
371370 if ( ! $got_form_def_from_cache ) {
372371 $form_def = $wgParser->parse( $form_def, $this->mPageTitle, $wgParser->mOptions )->getText();
373372 }
374 - $wgParser->mStripState = $old_strip_state;
375373
376374 // turn form definition file into an array of sections, one for each
377375 // template definition (plus the first section)

Follow-up revisions

RevisionCommit summaryAuthorDate
r82936Further improvements to $wgParser call, with help from Tim Starling; plus som...yaron15:51, 28 February 2011

Comments

#Comment by Tim Starling (talk | contribs)   03:43, 28 February 2011

It doesn't work with MW 1.16 or MW 1.18 or any other version, because you can't re-enter $wgParser->parse(). You should follow my instructions at Special:Code/MediaWiki/82645#c14491 instead.

#Comment by Yaron Koren (talk | contribs)   16:25, 28 February 2011

Thanks for the advice. I forgot to note it when checking it in, but r82936 is a follow-up to this one.

#Comment by Yaron Koren (talk | contribs)   16:26, 28 February 2011

Oh, I just discovered I can manually associate revisions together - this CodeReview thing is pretty neat!

Status & tagging log