Foxtrott has submitted this change and it was merged.

Change subject: bugfix (Exception: Serialization of 'Closure' is not allowed)
......................................................................


bugfix (Exception: Serialization of 'Closure' is not allowed)

Back in 2011 there was a problem where when a form was parsed bits of parser 
data (e.g. JavaScript links) were
included twice in the ParserOutput. What exactly the problem was and how it can 
be reproduced is not clear
anymore.

The solution back then was to deep clone the parser by serializing and 
unserializing it and then use the clone
for parsing the form. Just using a new Parser object was not possible as it 
misses the parser state from earlier
operations on the parser, e.g. by the MW core or other extensions.

In recent MediaWiki versions closures were introduced in the Parser (and/or its 
member variables), so
serialization now throws an exception. This patch removes the deep cloning, so 
that for parsing the form the
original parser is used again. This will likely lead to the old problematic 
behaviour, which will have to be
fixed without using serialization.

See 4c69d35b22f271dc95963d915f55248431202744 
(http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88564) 
and 647b5b49e90286c4f4a1638f9cb3222c1f08d804 
(http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88685)



Change-Id: I1262d2c9d478790e757abc42b0de017dafb4666b
---
M includes/SF_FormPrinter.php
1 file changed, 7 insertions(+), 5 deletions(-)

Approvals:
  Foxtrott: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/includes/SF_FormPrinter.php b/includes/SF_FormPrinter.php
index b7b5611..c4f9ee1 100644
--- a/includes/SF_FormPrinter.php
+++ b/includes/SF_FormPrinter.php
@@ -435,12 +435,14 @@
                        $wgOut->addHTML( "\n<hr />\n" );
                }
 
-               $oldParser = $wgParser;
+//             $oldParser = $wgParser;
 
-               $wgParser = unserialize( serialize( $oldParser ) ); // deep 
clone of parser
-               $wgParser->Options( ParserOptions::newFromUser( $wgUser ) );
+//             $wgParser = unserialize( serialize( $oldParser ) ); // deep 
clone of parser
+               if ( !$wgParser->Options() ) {
+                       $wgParser->Options( ParserOptions::newFromUser( $wgUser 
) );
+               }
                $wgParser->Title( $this->mPageTitle );
-               $wgParser->clearState();
+//             $wgParser->clearState();
 
                $form_def = SFFormUtils::getFormDefinition( $wgParser, 
$form_def, $form_id );
 
@@ -1613,7 +1615,7 @@
                $parserOutput = $wgParser->getOutput();
                $wgOut->addParserOutputNoText( $parserOutput );
 
-               $wgParser = $oldParser;
+//             $wgParser = $oldParser;
 
                wfProfileOut( __METHOD__ );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/64515
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1262d2c9d478790e757abc42b0de017dafb4666b
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to