Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values for SMW {{#show:}} calls reliably do not work on non-existing pages if the page we ask data from has any incoming properties. #3588

Closed
FO-nTTaX opened this issue Jan 10, 2019 · 7 comments · Fixed by #4078
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error
Milestone

Comments

@FO-nTTaX
Copy link
Contributor

FO-nTTaX commented Jan 10, 2019

Setup and configuration

  • SMW version: 3.0.0
  • MW version: 1.31.1
  • PHP version: 7.0.30-0+deb9u1 (apache2handler)
  • DB system (MySQL, Blazegraph, etc.) and version: 10.1.37-MariaDB-0+deb9u1

Issue

Default values for SMW {{#show:}} calls reliably do not work if the page we ask data from has any incoming properties. An example can be seen here: https://wiki.liquipedia.space/wiki/index.php/SMW_Default_Value

==Mentionned Page==
{{#show:SMW Mentionned Page|?has test|default=no data}}
==Not Mentionned Page==
{{#show:SMW Not Mentionned Page|?has test|default=no data}}

Both SMW Mentionned Page And SMW Not Mentionned Page page do not exist, but SMW Mentionned Page has incoming data as another page has the page title set as a property: https://wiki.liquipedia.space/wiki/index.php?title=SMW_Mentioning_Page&action=edit
See also https://wiki.liquipedia.space/wiki/index.php/Special:Browse?title=Special%3ABrowse&article=SMW+Mentionned+Page and https://wiki.liquipedia.space/wiki/index.php/Special:Browse?title=Special%3ABrowse&article=SMW+Not+Mentionned+Page

In https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/Query/ResultPrinters/ResultPrinter.php#L326 $results->getCount() will return 1 for SMW Mentionned Page, even though the page does not exist at all.

Steps to reproduce

I included a minimal testcase above, relevant URLs are

@kghbln kghbln added the bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error label Jan 12, 2019
@mwjames
Copy link
Contributor

mwjames commented Jan 12, 2019

I wanted to provide quick feedback!

Both SMW Mentionned Page And SMW Not Mentionned Page page do not exist, but SMW Mentionned Page has incoming data as another page has the page title set as a property

Incoming entities as those seen in Special:Browse and objects (entities) returned as result of a query are two different concepts that cannot be used as basis for a comparison.

The QueryEngine can return objects that don't exists as "MediaWiki" page but are recognized as "object" value especially when constructing or work with inverse conditions.

https://wiki.liquipedia.space/wiki/index.php/SMW_Default_Value

I haven't look at the issue at all and I won't find time within the next couple of weeks to attend this issue unless someone else can distill it and provide a fairly simple use (== test) case/scenario.

I appreciate the links and description but it would still require a considerable effort from my side to review the content, identify, and dissect the issue, so I'm asking others (@kghbln @hexmode @krabina @planetenxin @s7eph4n @jamesmontalvo3) to fill in the blanks allowing me not to be involved and answer each and every ticket.

@mwjames mwjames removed the bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error label Jan 12, 2019
@gesinn-it-gea
Copy link
Member

@FO-nTTaX does the issue occur after a change in the software environment (e.g. update)? Has a similar setup been working on a different software environment (e.g. with SMW 2.x)?

@FO-nTTaX
Copy link
Contributor Author

@gesinn-it We updated from 2.5.8 where it worked to 3.0.0 where it does not. We did not change anything but SMW, so I can pretty much exclude external factors (also that test wiki I linked has nothing else installed).

@mwjames
Copy link
Contributor

mwjames commented Jan 14, 2019

==Mentionned Page==
{{#show:SMW Mentionned Page|?has test|default=no data}}
==Not Mentionned Page==
{{#show:SMW Not Mentionned Page|?has test|default=no data}}

Premise

It should be noted that #show uses the list (or plainlist) as default format if no other format is specific and in your specific use case relying on default as output only applies for that format, any other format (e.g. table) would produce a different output (goes for both 3.+ and 2.5+).

Whether [[SMW Mentionned Page]] (or [[SMW Not Mentionned Page]]) exists in MW or not as page is irrelevant, in SMW it represents a valid entity in terms of its object space meaning that has an ID and can be used as referential object instance.

Issue

If I'm not mistaken then this relates to the #2488 (Rework List format) change. In 2.5.8 the ListResultPrinter would allow something like:

// Display default if the result is empty
if ( $result == '' ) {
$result = $this->params['default'];
}

while with 3.0 it returns '':

private function getFurtherResultsText( SMWQueryResult $res, $outputMode ) {
if ( $this->linkFurtherResults( $res) ) {
$link = $this->getFurtherResultsLink( $res, $outputMode );
return $link->getText( SMW_OUTPUT_WIKI, $this->mLinker );
}
return '';

Adding return $this->params['default']; should restore the previous behaviour.

Tasks

  • Confirm that above is the right conclusion
  • Test the fix
  • Write an integration test that covers the use case
  • Send a PR

@FO-nTTaX
Copy link
Contributor Author

The fix you have suggested seems to work on my test wiki from what I see after adding it to the file.

@kghbln kghbln added the bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error label Jan 17, 2019
@kghbln kghbln added this to the SMW 3.1.0 milestone Jan 17, 2019
@kghbln
Copy link
Member

kghbln commented Jan 17, 2019

Write an integration test that covers the use case

I will try to tackle this and send a PR together with it.

@FO-nTTaX
Copy link
Contributor Author

FO-nTTaX commented Jan 28, 2019

The fix you have suggested seems to work on my test wiki from what I see after adding it to the file.

Ok I have to retract that. On properties that do exist, this would actually print both the result AND the default text.

grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Occurrence of an unintended or unanticipated behaviour that causes a vulnerability or fatal error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants