SemanticMediaWiki / SemanticResultFormats

Provides additional visualizations (result formats) for Semantic MediaWiki
https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Result_Formats
Other
45 stars 75 forks source link

$node variable never set #742

Closed YOUR1 closed 1 year ago

YOUR1 commented 1 year ago

The $node variable in GraphPrinter https://github.com/SemanticMediaWiki/SemanticResultFormats/blob/993be1646e4c2df3a44d91c1c26505d5b744fcb4/src/Graph/GraphPrinter.php#L191 is not necessarily always set. Causing Fatal errors like:


[b21f02e9ee840c16d267cc9b] /index.php/Overzicht_RDA-klassen Error from line 190 of /var/platform/cores/1.35/20221104-1230/extensions/SemanticResultFormats/src/Graph/GraphPrinter.php: Call to a member function addField() on null

Backtrace:
#0 /var/platform/cores/1.35/20221104-1230/extensions/SemanticResultFormats/src/Graph/GraphPrinter.php(141): SRF\Graph\GraphPrinter->processResultRow(array)
#1 /var/platform/cores/1.35/20221104-1230/extensions/SemanticMediaWiki/src/Query/ResultPrinters/ResultPrinter.php(341): SRF\Graph\GraphPrinter->getResultText(SMW\Query\QueryResult, integer)
#2 /var/platform/cores/1.35/20221104-1230/extensions/SemanticMediaWiki/src/Query/ResultPrinters/ResultPrinter.php(306): SMW\Query\ResultPrinters\ResultPrinter->buildResult(SMW\Query\QueryResult)
#3 /var/platform/cores/1.35/20221104-1230/extensions/SemanticMediaWiki/includes/query/SMW_QueryProcessor.php(348): SMW\Query\ResultPrinters\ResultPrinter->getResult(SMW\Query\QueryResult, array, integer)
#4 /var/platform/cores/1.35/20221104-1230/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(364): SMWQueryProcessor::getResultFromQuery(SMWQuery, array, integer, integer)
#5 /var/platform/cores/1.35/20221104-1230/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(196): SMW\ParserFunctions\AskParserFunction->doFetchResultsFromFunctionParameters(array, array)
#6 /var/platform/cores/1.35/20221104-1230/extensions/SemanticMediaWiki/src/ParserFunctionFactory.php(402): SMW\ParserFunctions\AskParserFunction->parse(array)``` 
JeroenDeDauw commented 1 year ago

@alex-mashin you touched that in https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/676

alex-mashin commented 1 year ago

I presume, to get this error, one has to either suppress the main result column or move it from the first place, so that some non-page property becomes the first?

alex-mashin commented 1 year ago

The code assumed that '?' is the first printout.

alex-mashin commented 1 year ago

Can be closed now.