You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case the valid ParserOptions object passed to the Parser::parse method will not be set on the global Parser object. In the global object it may be null, 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 by Parser::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.
The text was updated successfully, but these errors were encountered:
{
"error": {
"code": "internal_api_error_Error",
"info":"[18e4c61e4d11b00628c7ec6f] Exception caught: Call to a member function getMaxIncludeSize() on null",
"errorclass":"Error",
"trace":"Error at ...."
}
}
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.
The text was updated successfully, but these errors were encountered: