Semanticmediawiki: Testing an existence of a subobject and then creating it if non-existent

Created on 24 May 2020  路  2Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

Setup and configuration

  • SMW version: 3.2.0-alpha
  • MW version: 1.34.1
  • PHP version: 7.2.24
  • MariaDB: 10.1.44

Question

This is a question, not an issue.
If I need to test an existence of a subobject and then creating it if non-existent, what should I have to do? Is it a paradox when I purge de page? Is there a better aproach?

I have an aways mutating result when I put the following code.
See it on sandbox: Click on "More > Refresh" more than once and look at the "exists" and "does not exist" messages.

{{#if: {{#show:{{FULLPAGENAME}}#Name
|?Has text
|format=plainlist
|link=none
|headers=hide
|mainlabel=-
}} | subobject exists (it won't create it) | subobject does not exist (now creating it)

{{#subobject:Name|Has text=This is a test, subobject is created}}

}}

Steps to reproduce

See: https://sandbox.semantic-mediawiki.org/wiki/Issue/4786

question

All 2 comments

Good question. In this case, since it is a named subobject, unconditionally creating it should probably work but this is not the answer. I suspect that I cannot be done out of the box.

Closing it because I believe there is nothing to do to make this work right now. James already answered many times [0] about how MediaWiki handle the processing>storage>retrieve of queries that is done in the same page (edit, revision) of the storage. So I guess this is somewhat expected.

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/2375

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mwjames picture mwjames  路  3Comments

jaideraf picture jaideraf  路  3Comments

djoris picture djoris  路  4Comments

plegault3397 picture plegault3397  路  3Comments

simontaurus picture simontaurus  路  3Comments