Open osnard opened 7 months ago
I can confirm this issue for the case a page with
{{#ask: [[Category:SomeProcessCategory]]
|?HasSuccessor
|format=graph
|graphlink=yes
|rankdir=TB
}}
is edited with the VisualEditor
{
"error": {
"code": "internal_api_error_Error",
"info":"[18e4c61e4d11b00628c7ec6f] Exception caught: Call to a member function getMaxIncludeSize() on null",
"errorclass":"Error",
"trace":"Error at ...."
}
}
Error at /var/www/html/w/includes/parser/Parser.php(2935)
from /var/www/html/w/includes/parser/Parser.php(2935)
#0 /var/www/html/w/includes/parser/Parser.php(1609): Parser->replaceVariables()
#1 /var/www/html/w/includes/parser/Parser.php(881): Parser->internalParse()
#2 /var/www/html/w/extensions/SemanticResultFormats/src/Graph/GraphPrinter.php(173): Parser->recursiveTagParse()
#3 /var/www/html/w/extensions/SemanticMediaWiki/src/Query/ResultPrinters/ResultPrinter.php(339): SRF\\Graph\\GraphPrinter->ge…ncludes/ApiVisualEditor.php(279): MediaWiki\\Extension\\VisualEditor\\ApiVisualEditor->requestRestbasePageHtml()
#34 /var/www/html/w/includes/api/ApiMain.php(1900): MediaWiki\\Extension\\VisualEditor\\ApiVisualEditor->execute()
#35 /var/www/html/w/includes/api/ApiMain.php(875): ApiMain->executeAction()
#36 /var/www/html/w/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()
#37 /var/www/html/w/api.php(90): ApiMain->execute()
#38 /var/www/html/w/api.php(45): wfApiMain()
#39 {main}
@kghbln, @JeroenDeDauw: Can you give us a hint where to inject a proper Parser object?
Some result formats (e.g. "filtered") seem to rely on the global
Parser
object. Example: https://github.com/SemanticMediaWiki/SemanticResultFormats/blob/4.1.0/formats/filtered/src/Filtered.php#L102This can lead to errors like
when the code gets executed in a context different from the regular index.php-request.
Background: In newer MediaWiki versions there is a dedicated
MediaWikiServices
service (ParserFactory
) to create new, independentParser
objectsExample for such code:
In this case the valid
ParserOptions
object passed to theParser::parse
method will not be set on the globalParser
object. In the global object it may benull
, depending on the context of this code (e.g. within a REST-API call).One could probably consider this an edge case, but relying on global state objects should be avoided in general.
Usually this would be solved by passing the
Parser
object provided by MediaWiki to the handler implementation of the{{#ask:}}
parser function (the callback registered byParser::setFunctionHook
) down to the result format. Unfortunately I didn't find a nice way to do that.Any suggestions are welcome. If you can give me a hint about how to properly solve this, I can submit a patch.