Semanticmediawiki: RuntimeException from line 58 of "SingleEntityQueryLookup.php"

Created on 9 Nov 2019  路  17Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

References

Post to the mailing list.

Setup and configuration

  • 1.31.0 MW
  • 7.1.30 (cgi-fcgi) PHP
  • 5.7.25 MySQL
  • 2.5.6 SMW

Issue

RuntimeException from line 58 of /../wiki/extensions/SemanticMediaWiki/src/SQLStore/Lookup/SingleEntityQueryLookup.php: Expected a ValueDescription instance!

Stack trace

Produces a stack trace and/or outputs:

#0 /../wiki/extensions/SemanticMediaWiki/includes/query/SMW_QueryProcessor.php(338): SMW\SQLStore\Lookup\SingleEntityQueryLookup->getQueryResult(SMWQuery)
#1 /../wiki/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(364): SMWQueryProcessor::getResultFromQuery(SMWQuery, array, integer, integer)
#2 /../wiki/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(197): SMW\ParserFunctions\AskParserFunction->doFetchResultsFromFunctionParameters(array, array)
#3 /../wiki/extensions/SemanticMediaWiki/src/ParserFunctions/ShowParserFunction.php(45): SMW\ParserFunctions\AskParserFunction->parse(array)
#4 /../wiki/extensions/SemanticMediaWiki/src/ParserFunctionFactory.php(428): SMW\ParserFunctions\ShowParserFunction->parse(array)
#5 /../wiki/includes/parser/Parser.php(3426): SMW\ParserFunctionFactory->SMW\{closure}(Parser, string, string)
#6 /../wiki/includes/parser/Parser.php(3127): Parser->callParserFunction(PPFrame_DOM, string, array)
#7 /../wiki/includes/parser/Preprocessor_DOM.php(1277): Parser->braceSubstitution(array, PPFrame_DOM)
#8 /../wiki/includes/parser/Parser.php(3045): PPFrame_DOM->expand(DOMElement)
#9 /../wiki/includes/parser/Preprocessor_DOM.php(1277): Parser->braceSubstitution(array, PPFrame_DOM)
#10 /../wiki/includes/parser/Parser.php(2942): PPFrame_DOM->expand(DOMElement, integer)
#11 /../wiki/includes/parser/Parser.php(1293): Parser->replaceVariables(string)
#12 /../wiki/includes/parser/Parser.php(443): Parser->internalParse(string)
#13 /../wiki/includes/content/WikitextContent.php(323): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#14 /../wiki/includes/content/AbstractContent.php(516): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput)
#15 /../wiki/extensions/SemanticMediaWiki/includes/ContentParser.php(186): AbstractContent->getParserOutput(Title, integer, ParserOptions, boolean)
#16 /../wiki/extensions/SemanticMediaWiki/includes/ContentParser.php(145): SMW\ContentParser->fetchFromContent()
#17 /../wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(197): SMW\ContentParser->parse()
#18 /../wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(137): SMW\MediaWiki\Jobs\UpdateJob->parse_content()
#19 /../wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(94): SMW\MediaWiki\Jobs\UpdateJob->doUpdate()
#20 /../wiki/extensions/SemanticMediaWiki/src/SQLStore/Rebuilder/Rebuilder.php(237): SMW\MediaWiki\Jobs\UpdateJob->run()
#21 /../wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(423): SMW\SQLStore\Rebuilder\Rebuilder->rebuild(integer)
#22 /../wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(349): SMW\Maintenance\DataRebuilder->do_update(integer)
#23 /../wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(200): SMW\Maintenance\DataRebuilder->rebuild_all()
#24 /../wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(202): SMW\Maintenance\DataRebuilder->rebuild()
#25 /../wiki/maintenance/doMaintenance.php(94): SMW\Maintenance\RebuildData->execute()
#26 /../wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(261): require_once(string)
#27 {main}

Steps to reproduce

I am trying to upgrade my SMW from 2.5.6 to 3.1 by following this tutorial: upgrade Everything until step 6 works just fine. Once I run the "rebuildData.php" I get the following exception after a while: pastebin Does someone know what is causing this and how could I get it fixed?

bug

All 17 comments

To you happen to have another extension aboard for which you have not updated the dependencies after the upgrade? This topic on mw.o looks pretty similar to me.

I looked at this code but its not clear to me what is wrong. @mwjames this is one of the things you added recently

To you happen to have another extension aboard for which you have not updated the dependencies after the upgrade? This topic on mw.o looks pretty similar to me.

I made sure to download and upload fresh copies of all my extensions before actully trying to update and rebuild.

I made sure to download and upload fresh copies of all my extensions before actully trying to update and rebuild.

Good to know. Thus we can rule out something like this.

RuntimeException from line 58 of /../wiki/extensions/SemanticMediaWiki/src/SQLStore/Lookup/SingleEntityQueryLookup.php: Expected a ValueDescription instance!

I added the exception for a reason because the code path should never
reach this point but now that it did we need to know what sort of
query would cause the exception case.

SingleEntityQueryLookup is only reachable via a #show (as noted in
the comment of the class) query and I'd like to know how this #show
looks like so that we can design a test case that would fail in a
deterministic way because returning an empty QueryResult would be
simple but I would hide the fact that some conditions were injected we
hadn't anticipated.

How to move forward?

You should run your rebuild with the skip exception argument (see the
doc for details) and isolate the ID (-v outputs the title) that would
cause above condition and look at the wiki text and report back what

show query is causing the issue.

On 11/10/19, Karsten Hoffmeyer notifications@github.com wrote:

I made sure to download and upload fresh copies of all my extensions
before actully trying to update and rebuild.

Good to know. Thus we can rule out something like this.

--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/4349#issuecomment-552182771

SingleEntityQueryLookup is only reachable via a #show (as noted in
the comment of the class) query and I'd like to know how this #show
looks like so that we can design a test case that would fail in a

Unless someone provides instructions on how to replicate the issue, I will close this ticket by next week as observations are not replicable. (It has been 2 month since I responded to the issue!!)

@MukiA It will be great if you could dig into this

How to move forward?

You should run your rebuild with the skip exception argument (see the
doc for details) and isolate the ID (-v outputs the title) that would
cause above condition and look at the wiki text and report back what

show query is causing the issue.

The command:

php rebuildData.php -v --ignore-exceptions 

You will see a number connected to the exception in your shell. With this number you go to special page "SemanticMediaWiki" - "Supplementary functions" - "Entity lookup and disposal" (../index.php?title=Special:SemanticMediaWiki&action=lookup) and fill it in the respective interface. Please paste the result here. See also object ID lookup.

@kghbln We were able to independently reproduce this on our own system.

The most basic Wikitext needed to cause the exception seems to be:

{{#show:[[]][[]]}}

There must be two sets of [[]] anywhere in the first argument but it doesn't matter what appears within either set of [[]]. The second parameter is also irrelevant to this failure mode, valid or invalid, provided or not.

Other examples:
_-- does not throw exception --_

{{#show:[[Display title of::page_with_display_title]]}} 

_-- throws exception --_

{{#show:[[Display title of::page_with_display_title]][[]]]}}
{{#show:[[]][[Display title of::page_with_display_title]]}}
{{#show:[[Display title of::page_with_display_title]][[Display title of::page_with_display_title]]}}
{{#show:[[Display title of::page_with_display_title]] [[Display title of::page_with_display_title]]}}
{{#show:sdf[[]]asdasd[[]]asd}}

Our System configuration:

  • MediaWiki - 1.34.0聽(6046a49)
  • PHP - 7.2.19 (apache2handler)
  • MySQL - 5.6.44
  • Semantic MediaWiki - 3.1.5

@kji-mitre Thanks for digging into this and shedding some light on the cause of this issue. Admittedly the cause also reveals why we had not enough fantasy to come up with it. Basically we see a misuse (the docu is indeed not explicit here) of the #show parser function here since it is only meant to hold one argument as opposed to #ask. I was not even aware that you could add a property as an search argument to be frank. Anyways, to cut a long story short: Having more than one argument is a feature request.

{{#show:[[Display title of::page_with_display_title]][[]]]}}

I understand the issue now besides that #show is being wrongly used here it will ultimately lead to an error but given the example, I'm able to reproduce issue and can make the exception go away.

It remains though that using #show is expected as {{#show: Demo:Berlin |?Population }} while #ask uses the form of {{#ask: [[Demo:Berlin]] |?Population= |mainlabel=- }} [0].

I was not even aware that you could add a property as an search argument to be frank. Anyways, to cut a long story short: Having more than one argument is a feature request.

No. #show is provided for the single entity (page entity) lookup use case.

[0] https://www.semantic-mediawiki.org/wiki/Help:Inline_queries#Parser_function_.23show

I added the exception for a reason because the code path should never
reach this point but now that it did we need to know what sort of
query would cause the exception case.

As I mentioned above, the exception was there for a reason which helped us identify some ill defined usage pattern which of course shouldn't raise an exception. Now, that we have retrieved some use cases to test against they remain part of the overall tests in future (for details see the p-0213.json).

Part of the problem was also the documentation provided, which I hopefully have improved now.

the documentation provided, which I hopefully have improved now.

I just looked at the docu and we should think about splitting this mammoth into manageable pieces to be consumable otherwise there is too much text to be confronted with.

I'm so sorry, I don't use Github and completely forgot about this since I updated to SMW 3.0.2 without any issues and just left it at that.

@kghbln Not sure how relevant this is but I ran your suggested command php rebuildData.php -v --ignore-exceptions and got the following exception:

... updating 332550    [S: smw/schema:Group:Schema_properties]
... updating 332559    [S: Chilblains#3012#_QUERYdac2b999dab756c5b09846188e82632d]

... IDs checked or refreshed                    39988
... IDs skipped                                 0
... done.
[d9466933acac0a733272b88d] [no req]   SMW\Exception\FileNotWritableException from line 39 of /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Utils/File.php: /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance../../../rebuilddata-exceptions-2020-03-23.log is not writable.
Backtrace:
#0 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/ExceptionFileLogger.php(129): SMW\Utils\File->write(string, string, integer)
#1 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/ExceptionFileLogger.php(115): SMW\Maintenance\ExceptionFileLogger->put(integer, array)
#2 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(405): SMW\Maintenance\ExceptionFileLogger->doWrite()
#3 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(200): SMW\Maintenance\DataRebuilder->rebuild_all()
#4 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(202): SMW\Maintenance\DataRebuilder->rebuild()
#5 /home/domain/public_html/dev2/wiki/maintenance/doMaintenance.php(94): SMW\Maintenance\RebuildData->execute()
#6 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(261): require_once(string)
#7 {main}
[root@server wiki]#

I read through this thread but didn't really understand what to do to get this sorted out, I am still unable to upgrade SMW without exceptions as I tried again from 3.0.2 to 3.1.5.

@MukiA

/home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance../../../rebuilddata-exceptions-2020-03-23.log is not writable.

This error just tells you that the location to write the log file to is not writable for SMW. You can specify a location with the --exception-log flag like e.g. --exception-log="/path/to/smw/logs/directory/"

@kghbln I managed to get it to write to the file, it caught 2 exceptions:

... IDs checked or refreshed          39980
... IDs skipped                               0
... done.

Exception log ...
... counted 2 exceptions
... written to ... rebuilddata-exceptions-2020-03-24.log
... done.
======== EXCEPTION ======
10288 | Expected a ValueDescription instance!

#0 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/includes/query/SMW_QueryProcessor.php(338): SMW\SQLStore\Lookup\SingleEntityQueryLookup->getQueryResult(Object(SMWQuery))
#1 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(364): SMWQueryProcessor::getResultFromQuery(Object(SMWQuery), Array, 2, 1004)
#2 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(197): SMW\ParserFunctions\AskParserFunction->doFetchResultsFromFunctionParameters(Array, Array)
#3 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctions/ShowParserFunction.php(45): SMW\ParserFunctions\AskParserFunction->parse(Array)
#4 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctionFactory.php(428): SMW\ParserFunctions\ShowParserFunction->parse(Array)
#5 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(3426): SMW\ParserFunctionFactory->SMW\{closure}(Object(Parser), 'Trait:', '?Has game conte...')
#6 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(3127): Parser->callParserFunction(Object(PPFrame_DOM), 'show', Array)
#7 /home/domain/public_html/dev2/wiki/includes/parser/Preprocessor_DOM.php(1277): Parser->braceSubstitution(Array, Object(PPFrame_DOM))
#8 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(3045): PPFrame_DOM->expand(Object(DOMElement))
#9 /home/domain/public_html/dev2/wiki/includes/parser/Preprocessor_DOM.php(1277): Parser->braceSubstitution(Array, Object(PPFrame_DOM))
#10 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(2942): PPFrame_DOM->expand(Object(DOMElement), 0)
#11 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(1293): Parser->replaceVariables('{{#ifeq: {{#sho...')
#12 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(443): Parser->internalParse('{{#ifeq: {{#sho...')
#13 /home/domain/public_html/dev2/wiki/includes/content/WikitextContent.php(323): Parser->parse('{{#ifeq: {{#sho...', Object(Title), Object(ParserOptions), true, true, 51052)
#14 /home/domain/public_html/dev2/wiki/includes/content/AbstractContent.php(516): WikitextContent->fillParserOutput(Object(Title), 51052, Object(ParserOptions), true, Object(ParserOutput))
#15 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/includes/ContentParser.php(186): AbstractContent->getParserOutput(Object(Title), 51052, Object(ParserOptions), true)
#16 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/includes/ContentParser.php(145): SMW\ContentParser->fetchFromContent()
#17 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(197): SMW\ContentParser->parse()
#18 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(137): SMW\MediaWiki\Jobs\UpdateJob->parse_content()
#19 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(94): SMW\MediaWiki\Jobs\UpdateJob->doUpdate()
#20 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/SQLStore/Rebuilder/Rebuilder.php(237): SMW\MediaWiki\Jobs\UpdateJob->run()
#21 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(427): SMW\SQLStore\Rebuilder\Rebuilder->rebuild(10288)
#22 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(349): SMW\Maintenance\DataRebuilder->do_update(10288)
#23 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(200): SMW\Maintenance\DataRebuilder->rebuild_all()
#24 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(202): SMW\Maintenance\DataRebuilder->rebuild()
#25 /home/domain/public_html/dev2/wiki/maintenance/doMaintenance.php(94): SMW\Maintenance\RebuildData->execute()
#26 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(261): require_once('/home/domain...')
#27 {main}
======== END ======

======== EXCEPTION ======
10776 | Expected a ValueDescription instance!

#0 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/includes/query/SMW_QueryProcessor.php(338): SMW\SQLStore\Lookup\SingleEntityQueryLookup->getQueryResult(Object(SMWQuery))
#1 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(364): SMWQueryProcessor::getResultFromQuery(Object(SMWQuery), Array, 2, 1004)
#2 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctions/AskParserFunction.php(197): SMW\ParserFunctions\AskParserFunction->doFetchResultsFromFunctionParameters(Array, Array)
#3 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctions/ShowParserFunction.php(45): SMW\ParserFunctions\AskParserFunction->parse(Array)
#4 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/ParserFunctionFactory.php(428): SMW\ParserFunctions\ShowParserFunction->parse(Array)
#5 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(3426): SMW\ParserFunctionFactory->SMW\{closure}(Object(Parser), 'Skill:', '?Has game conte...')
#6 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(3127): Parser->callParserFunction(Object(PPFrame_DOM), 'show', Array)
#7 /home/domain/public_html/dev2/wiki/includes/parser/Preprocessor_DOM.php(1277): Parser->braceSubstitution(Array, Object(PPFrame_DOM))
#8 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(3045): PPFrame_DOM->expand(Object(DOMElement))
#9 /home/domain/public_html/dev2/wiki/includes/parser/Preprocessor_DOM.php(1277): Parser->braceSubstitution(Array, Object(PPFrame_DOM))
#10 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(2942): PPFrame_DOM->expand(Object(DOMElement), 0)
#11 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(1293): Parser->replaceVariables('{{#ifeq: {{#sho...')
#12 /home/domain/public_html/dev2/wiki/includes/parser/Parser.php(443): Parser->internalParse('{{#ifeq: {{#sho...')
#13 /home/domain/public_html/dev2/wiki/includes/content/WikitextContent.php(323): Parser->parse('{{#ifeq: {{#sho...', Object(Title), Object(ParserOptions), true, true, 51051)
#14 /home/domain/public_html/dev2/wiki/includes/content/AbstractContent.php(516): WikitextContent->fillParserOutput(Object(Title), 51051, Object(ParserOptions), true, Object(ParserOutput))
#15 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/includes/ContentParser.php(186): AbstractContent->getParserOutput(Object(Title), 51051, Object(ParserOptions), true)
#16 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/includes/ContentParser.php(145): SMW\ContentParser->fetchFromContent()
#17 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(197): SMW\ContentParser->parse()
#18 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(137): SMW\MediaWiki\Jobs\UpdateJob->parse_content()
#19 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Jobs/UpdateJob.php(94): SMW\MediaWiki\Jobs\UpdateJob->doUpdate()
#20 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/SQLStore/Rebuilder/Rebuilder.php(237): SMW\MediaWiki\Jobs\UpdateJob->run()
#21 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(427): SMW\SQLStore\Rebuilder\Rebuilder->rebuild(10776)
#22 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(349): SMW\Maintenance\DataRebuilder->do_update(10776)
#23 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/src/Maintenance/DataRebuilder.php(200): SMW\Maintenance\DataRebuilder->rebuild_all()
#24 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(202): SMW\Maintenance\DataRebuilder->rebuild()
#25 /home/domain/public_html/dev2/wiki/maintenance/doMaintenance.php(94): SMW\Maintenance\RebuildData->execute()
#26 /home/domain/public_html/dev2/wiki/extensions/SemanticMediaWiki/maintenance/rebuildData.php(261): require_once('/home/domain...')
#27 {main}
======== END ======

Is it safe to ignore those exceptions and move on? If no, what would you suggest to do? One last question, not sure if this is related to the exceptions but it seems like some text strings are missing after the upgrade: https://i.gyazo.com/edb34db76d1b414c898146c828021198.png

You are probably using invalid syntax on these two pages. See the conversation starting here: https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/4349#issuecomment-595973209 I'd fix it. To find pages to the two IDs have a look at the ID lookup docu.

The question about the missing strings is completely unrelated. You should have them in your wiki. Check at "MediaWiki:Smw-admin-tab-maintenance" if this page contains some text. This was part of 3.1.5 so I'm not sure why it is missing.

Was this page helpful?
0 / 5 - 0 ratings