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

Different behavior between #show and #ask with self-referencing parameters #1478

Closed
KrazyMax opened this issue Mar 26, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@KrazyMax
Copy link

commented Mar 26, 2016

Setup and configuration

  • SMW version: 2.3.1
  • MW version: 1.26.2
  • DB (MySQL etc.):

Issue

Hello everyone,

This is more a question than an issue, since I found a (non-satisfaying) way to solve my issue.

On a template of my wiki, I created parameters self-referencing. You will find a lighter example on [0] and [1] of what I did. Of course, in order not to call non defined-yet parameters, I use whenever I can local variables (thanks to the Variables extension), and only when I am sure that the value of my variable won't change, I #set the value of my parameter.

One strange thing I can not reproduce on SMW sandbox, is that if I use #show (which is way more simpler and cleaner than #ask when looking for the value of only one parameter), the output is blank. What really disturbs me is that using #ask will actually show me the right output!

Can something explain why I could have such a difference of result on my wiki?

Once again, this is not a real issue because #ask does work, but I am a bit affraid that one day nothing will work! I like to know a minima how does everything work and why it works that way.

Thank you in advance for the time you will take to answer me!

[0] http://sandbox.semantic-mediawiki.org/wiki/Is_Calling
[1] http://sandbox.semantic-mediawiki.org/wiki/Will_Be_Called

@mwjames

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2016

This [0] should give some insights on the topic of self-reference.

Can something explain why I could have such a difference of result on my wiki?

The sandbox is using 2.4-alpha which comes with the default deferred update mode (#1435) and it has the QueryDependencyLinksStore enabled which will purge the parser cache for registered queries which allows some of the self-referenced values being refreshed after a page has been saved.

[0] https://www.semantic-mediawiki.org/wiki/Help:Self-Referencing

@KrazyMax

This comment has been minimized.

Copy link
Author

commented Mar 27, 2016

Thanks for your link, hopefully my own code is coherent with the proper way to self-reference!

Ok, so it's about automatically refreshing the parser cache which is not done yet, but should be in 2.4 version of SMW. Good to know!

But still, to me {{ #show: Page | ?Property }} is just a kind of shortcut, equivalent to {{ #ask: [[Page]] | ?Property= | mainlabel=- }}, the refreshing issue should be observed for both of them, shouldn't it?

@mwjames

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2016

automatically refreshing the parser cache which is not done yet, but should be in 2.4 version of SMW.

Not really, the comment was made in connection with how MW execute updates and how SWM corresponds to those changes.

In general, the ParserCache is the cause for #ask / #show output sometimes being outdated and the QueryDependencyLinksStore tries to help with resolving dependencies and invalidation of the ParserCache.

Self-references are somewhat troublesome because a #ask/#show can only query what is stored in the DB and by time of the result display #ask can only generate from what "exists" in the DB and if it happens that DB updates are pending then expected changes from a subject might not yet be available (because the transaction is still in process).

is just a kind of shortcut, equivalent to

This is correct, the underlying code is the same [0, 1].

refreshing issue should be observed for both of them, shouldn't it?

It depends on when the update is finished (which could be queued, deferred etc) and whether the parser cache is outdated or not when the view event is triggered.

One could improve the situation with "pure" self-references that do not involve setting values via a template but as soon as templates are involved it is getting complicated because the template execution does happen in another transaction and can even be pushed into a job.

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/includes/parserhooks/AskParserFunction.php
[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/includes/parserhooks/ShowParserFunction.php

@mwjames

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2016

can only query what is stored in the DB and by time of the result display #ask can only generate from what "exists" in the DB and if it happens that DB updates are pending then expected changes from a subject might not yet be available (because the transaction is still in process).

For the given reasons, #1696 is hinting how to improve the situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.