Last modified: 2014-11-18 06:08:36 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T68202, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 66202 - Error when using Special:RunQuery - "Parser state cleared while parsing"
Error when using Special:RunQuery - "Parser state cleared while parsing"
Status: UNCONFIRMED
Product: MediaWiki extensions
Classification: Unclassified
SemanticForms (Other open bugs)
master
All All
: Unprioritized normal with 1 vote (vote)
: ---
Assigned To: Yaron Koren
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-05 17:19 UTC by Chris Koerner
Modified: 2014-11-18 06:08 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Chris Koerner 2014-06-05 17:19:41 UTC
I'm seeing a similar error as this bug (https://bugzilla.wikimedia.org/show_bug.cgi?id=65826) with 1.24wmf4 and Semantic Forms 2.7. This is the message I get when trying to use a Special:RunQuery embeded in a page. I get same error if I visit Special:RunQuery/FormNameHere

MediaWiki internal error.

Original exception: [c01a2a06] [no req] Exception from line 6391 of /var/www/html/w/includes/parser/Parser.php: Parser state cleared while parsing. Did you call Parser::parse recursively?
Backtrace:
#0 /var/www/html/w/includes/parser/Parser.php(475): Parser->lock()
#1 /var/www/html/w/extensions/SemanticForms/includes/SF_FormUtils.php(425): Parser->parse(string, Title, ParserOptions)
#2 /var/www/html/w/extensions/SemanticForms/includes/SF_FormPrinter.php(500): SFFormUtils::getFormDefinition(Parser, string, integer)
#3 /var/www/html/w/extensions/SemanticForms/specials/SF_RunQuery.php(79): SFFormPrinter->formHTML(string, boolean, boolean, integer, NULL, NULL, NULL, boolean, boolean)
#4 /var/www/html/w/extensions/SemanticForms/specials/SF_RunQuery.php(30): SFRunQuery->printPage(string, boolean)
#5 /var/www/html/w/includes/specialpage/SpecialPage.php(379): SFRunQuery->execute(string)
#6 /var/www/html/w/includes/specialpage/SpecialPageFactory.php(507): SpecialPage->run(string)
#7 /var/www/html/w/includes/specialpage/SpecialPageFactory.php(546): SpecialPageFactory::executePath(Title, RequestContext, boolean)
#8 /var/www/html/w/includes/parser/Parser.php(3594): SpecialPageFactory::capturePath(Title, RequestContext)
#9 /var/www/html/w/includes/parser/Preprocessor_DOM.php(1165): Parser->braceSubstitution(array, PPTemplateFrame_DOM)
#10 /var/www/html/w/includes/parser/Parser.php(3673): PPFrame_DOM->expand(PPNode_DOM)
#11 /var/www/html/w/includes/parser/Preprocessor_DOM.php(1165): Parser->braceSubstitution(array, PPFrame_DOM)
#12 /var/www/html/w/includes/parser/Parser.php(3326): PPFrame_DOM->expand(PPNode_DOM, integer)
#13 /var/www/html/w/includes/parser/Parser.php(1338): Parser->replaceVariables(string)
#14 /var/www/html/w/includes/parser/Parser.php(506): Parser->internalParse(string)
#15 /var/www/html/w/extensions/SemanticForms/specials/SF_RunQuery.php(99): Parser->parse(string, Title, ParserOptions)
#16 /var/www/html/w/extensions/SemanticForms/specials/SF_RunQuery.php(30): SFRunQuery->printPage(string, boolean)
#17 /var/www/html/w/includes/specialpage/SpecialPage.php(379): SFRunQuery->execute(string)
#18 /var/www/html/w/includes/specialpage/SpecialPageFactory.php(507): SpecialPage->run(string)
#19 /var/www/html/w/includes/Wiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)
#20 /var/www/html/w/includes/Wiki.php(599): MediaWiki->performRequest()
#21 /var/www/html/w/includes/Wiki.php(451): MediaWiki->main()
#22 /var/www/html/w/index.php(46): MediaWiki->run()
#23 {main}

Exception caught inside exception handler: [37f9f47f] [no req] Exception from line 1334 of /var/www/html/w/includes/WebRequest.php: FauxRequest::getRequestURL() not implemented
Backtrace:
#0 /var/www/html/w/includes/WebRequest.php(1385): FauxRequest->notImplemented(string)
#1 /var/www/html/w/includes/SkinTemplate.php(1162): FauxRequest->getRequestURL()
#2 /var/www/html/w/includes/SkinTemplate.php(534): SkinTemplate->buildContentNavigationUrls()
#3 /var/www/html/w/includes/SkinTemplate.php(257): SkinTemplate->prepareQuickTemplate(OutputPage)
#4 /var/www/html/w/includes/OutputPage.php(2146): SkinTemplate->outputPage()
#5 /var/www/html/w/includes/exception/MWException.php(220): OutputPage->output()
#6 /var/www/html/w/includes/exception/MWException.php(263): MWException->reportHTML()
#7 /var/www/html/w/includes/exception/MWExceptionHandler.php(45): MWException->report()
#8 /var/www/html/w/includes/exception/MWExceptionHandler.php(141): MWExceptionHandler::report(MWException)
#9 /var/www/html/w/includes/Wiki.php(465): MWExceptionHandler::handle(MWException)
#10 /var/www/html/
Comment 1 Chris Koerner 2014-07-23 16:25:05 UTC
I've discovered the cause of this error. Using Special:RunQuery inside of the Template used to format the results of said query/form will throw this error.

I was trying to place a Special:RunQuery search box on the results page somewhere other than the top or bottom.

{{Special:RunQuery/_formname_}}

Full template can be found here: http://pastebin.com/uNALQimx
Comment 2 Jaider Andrade Ferreira 2014-10-06 23:09:29 UTC
The same thing occurs to me.

Semantic Forms: 2.8 (8239268)
MediaWiki: 1.24alpha (c0bd3b7)

Error message:

MediaWiki internal error.

Original exception: [928a2657] [no req] 
Exception from line 6347 of /w/includes/parser/Parser.php: 
Parser state cleared while parsing. Did you call Parser::parse recursively?
Backtrace:
#0 /w/includes/parser/Parser.php(374): Parser->lock()
#1 /w/extensions/SemanticForms/includes/SF_FormUtils.php(428): Parser->parse(string, Title, ParserOptions)
#2 /w/extensions/SemanticForms/includes/SF_FormPrinter.php(501): SFFormUtils::getFormDefinition(Parser, string, integer)
#3 /w/extensions/SemanticForms/specials/SF_RunQuery.php(79): SFFormPrinter->formHTML(string, boolean, boolean, integer, NULL, NULL, NULL, boolean, boolean)
#4 /w/extensions/SemanticForms/specials/SF_RunQuery.php(30): SFRunQuery->printPage(string, boolean)
#5 /w/includes/specialpage/SpecialPage.php(363): SFRunQuery->execute(string)
#6 /w/includes/specialpage/SpecialPageFactory.php(562): SpecialPage->run(string)
#7 /w/includes/specialpage/SpecialPageFactory.php(601): SpecialPageFactory::executePath(Title, RequestContext, boolean)
#8 /w/includes/parser/Parser.php(3549): SpecialPageFactory::capturePath(Title, RequestContext)
#9 /w/includes/parser/Preprocessor_DOM.php(1179): Parser->braceSubstitution(array, PPFrame_DOM)
#10 /w/includes/parser/Parser.php(3281): PPFrame_DOM->expand(PPNode_DOM, integer)
#11 /w/includes/parser/Parser.php(1239): Parser->replaceVariables(string)
#12 /w/includes/parser/Parser.php(405): Parser->internalParse(string)
#13 [internal function]: Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#14 /w/includes/StubObject.php(105): call_user_func_array(array, array)
#15 /w/includes/StubObject.php(125): StubObject->_call(string, array)
#16 /w/includes/content/WikitextContent.php(338): StubObject->__call(string, array)
#17 /w/includes/content/WikitextContent.php(338): StubObject->parse(string, Title, ParserOptions, boolean, boolean, integer)
#18 /w/includes/content/AbstractContent.php(490): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput)
#19 /w/includes/poolcounter/PoolWorkArticleView.php(139): AbstractContent->getParserOutput(Title, integer, ParserOptions)
#20 /w/includes/poolcounter/PoolCounterWork.php(123): PoolWorkArticleView->doWork()
#21 /w/includes/page/WikiPage.php(1173): PoolCounterWork->execute()
#22 /w/includes/diff/DifferenceEngine.php(615): WikiPage->getParserOutput(ParserOptions, integer)
#23 /w/includes/diff/DifferenceEngine.php(592): DifferenceEngine->getParserOutput(WikiPage, Revision)
#24 /w/includes/diff/DifferenceEngine.php(451): DifferenceEngine->renderNewRevision()
#25 /w/includes/page/Article.php(809): DifferenceEngine->showDiffPage(boolean)
#26 /w/includes/page/Article.php(515): Article->showDiffPage()
#27 /w/includes/actions/ViewAction.php(44): Article->view()
#28 /w/includes/MediaWiki.php(414): ViewAction->show()
#29 /w/includes/MediaWiki.php(282): MediaWiki->performAction(Article, Title)
#30 /w/includes/MediaWiki.php(584): MediaWiki->performRequest()
#31 /w/includes/MediaWiki.php(435): MediaWiki->main()
#32 /w/index.php(46): MediaWiki->run()
#33 {main}

Exception caught inside exception handler: [9a57f917] [no req] Exception from line 1287 of /w/includes/WebRequest.php: FauxRequest::getRequestURL() not implemented
Backtrace:
#0 /w/includes/WebRequest.php(1338): FauxRequest->notImplemented(string)
#1 /w/includes/skins/SkinTemplate.php(1147): FauxRequest->getRequestURL()
#2 /w/includes/skins/SkinTemplate.php(523): SkinTemplate->buildContentNavigationUrls()
#3 /w/includes/skins/SkinTemplate.php(274): SkinTemplate->prepareQuickTemplate(OutputPage)
#4 /w/includes/OutputPage.php(2186): SkinTemplate->outputPage()
#5 /w/includes/exception/MWException.php(195): OutputPage->output()
#6 /w/includes/exception/MWException.php(238): MWException->reportHTML()
#7 /w/includes/exception/MWExceptionHandler.php(45): MWException->report()
#8 /w/includes/exception/MWExceptionHandler.php(141): MWExceptionHandler::report(MWException)
#9 /w/includes/MediaWiki.php(449): MWExceptionHandler::handle(MWException)
#10 /w/index.php(46): MediaWiki->run()
#11 {main}
Comment 3 Yaron Koren 2014-10-07 03:42:57 UTC
Yes, trying to embed Special:RunQuery has led to problems for a while now - and it seems to have gotten worse since MediaWiki 1.24, when calling the parser within a wiki page has apparently become all but impossible. I need to better understand the parser changes that happened in 1.24, but I'm not optimistic about this specific issue.
Comment 4 Masin Al-Dujaili 2014-10-31 12:58:46 UTC
If I change line 428 in extensions/SemanticForms/includes/SF_FormUtils.php:
$output = $parser->parse( $form_def, $title, $parser->getOptions());
to
$output = $parser->parse( $form_def, $title, $parser->getOptions(), true, false);
Special:RunQuery works as expected. Or it seems so at least.

But what did I do? I changed the parameter $clearState of parse() to something else than its default of 'true'. What does $clearState mean in this context?
Comment 5 Silke Meyer (WMDE) 2014-11-03 10:36:18 UTC
Hi Yaron, can you please comment on Masin's comment? Is it a solution? I can't tell myself... Thanks!
Best, Silke
Comment 6 Yaron Koren 2014-11-03 15:27:41 UTC
Oh, I didn't realize that the previous post was a proposed solution. It's great that this may fix the issue. I'm adding Stephan to this discussion - parser stuff in SF is essentially his work. Stephan, what do you think?
Comment 7 Masin Al-Dujaili 2014-11-04 10:00:55 UTC
Meanwhile, I have been told extensions shouldn't use Parser::parse() at all but rather Parser::recursiveTagParse(). So I changed those lines in SF_FormUtils.php to:

		$output = $parser->recursiveTagParse( $form_def );
		$form_def = $stripState->unstripGeneral( $output );

As I don't fully understand the neccessities of the following lines, I commented them out. recursiveTagParse does not return a ParserOutput object, so adapting those lines doesn't look feasible at all.

/*		if ( $output->getCacheTime() == -1 ) {
			$form_article = Article::newFromID( $form_id );
			self::purgeCache( $form_article );
			wfDebug( "Caching disabled for form definition $form_id\n" );
		} elseif ( $form_id !== null ) {
			self::cacheFormDefinition( $form_id, $form_def, $parser );
		}*/

Result: Works as well with our usecase. There might be some ratio to using Parser::parse() instead of Parser::recursiveTagParse() but I can't see it at the moment.
Comment 8 Yaron Koren 2014-11-18 06:08:36 UTC
Masin - thanks for looking into this, and sorry about the delay. In your code, you seem to have hit on the main reason for using parse() instead of recursiveTagParse(), which is that it allows for caching forms. I would hate to remove the caching functionality unless it's necessary... would you say your earlier solution, of adding more arguments into the parse() call, is a complete solution in itself?

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links