s7eph4n / PurgePage

Other
3 stars 0 forks source link

SMW and query subject dependencies #1

Open mwjames opened 8 years ago

mwjames commented 8 years ago

This can be useful, when the content of Bar depends on Foo, e.g. when using a SemanticMediawiki query on Bar that contains data from Foo in the results.

FYI

$GLOBALS['smwgEnabledQueryDependencyLinksStore'] = true; setting should help automatically determine query subject dependencies and invalidated the parser cache on those pages and force a re-parse. To avoid stress on the back-end, I refrained from doing a doPurge and instead rely on Title::invalidateCache to reset the cache state.

2.4 comes with an extra smwgQueryDependencyAffiliatePropertyDetectionlist [0].

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/83072ec22fa2319404c4d78bd7d51256a7d289d1/DefaultSettings.php#L894-L904

s7eph4n commented 8 years ago

Ooh, nice. I think I might have missed smwgEnabledQueryDependencyLinksStore. Will have a look at it. Thanks for pointing it out.

And I'll have to think on smwgQueryDependencyAffiliatePropertyDetectionlist. Not sure I understand what it does.

mwjames commented 8 years ago

And I'll have to think on smwgQueryDependencyAffiliatePropertyDetectionlist. Not sure I understand what it does.

I guess the description needs a bit more "fluff" (@kghbln would say) and is basically the result of the https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1617 discussion.

mwjames commented 8 years ago

I think I might have missed smwgEnabledQueryDependencyLinksStore. Will have a look at it. Thanks for pointing it out.

https://www.semantic-mediawiki.org/wiki/Help:Embedded_query_update might help as well.

mwjames commented 8 years ago

And I'll have to think on smwgQueryDependencyAffiliatePropertyDetectionlist. Not sure I understand what it does.

Added a small schematic to https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/1626.

s7eph4n commented 8 years ago

Ah, ok, much more clear now, Thanks! What I still do not understand is how the DISPLAYTITLE of a page can change without changing the page? Up to now I thought "subject" and "page" were synonym, but maybe not?

mwjames commented 8 years ago

What I still do not understand is how the DISPLAYTITLE of a page can change without changing the page? Up to now I thought "subject" and "page" were synonym, but maybe not?

Under normal circumstances the QueryDependencyLinksStore acts only on value changes that are part of a query description. Subjects are a special case, namely being the result of a query and if a subject (as object value) is deleted or nor longer part of a query result then an update is triggered.

Now, if a subject (as page) that is part of the result list changes some if its values (we only care for the property not for the values itself as we only want to detect a change state) that are not part of a query description then no update is triggered because no notable change occurred in light of what the query is expected to represent.

An affiliate makes it an exception that even though the DISPLAYTITLE is not part of a query description, any modification to it will trigger an update, if the related subject is part of a query (as description or as result).

QueryDependencyLinksStore does (simplified):

For example, you add a new page with [[Some property::Foo]] then the simple QueryDependencyLinksStore heuristic is not to waste precious computing on running a query trying to match an exact description (which would imply to account for limit/offset etc.) but instead it looks for all queries that contains Some property (happens in batch) and then fires a Title::invalidateCache on those subjects that have been linked to a query and contained a Some property.

Of course, you will have some false positive because of the value condition (e.g.Foo) where a different query like [[Some property::Bar]] could or could not result in the same result list but remember, we only invalidate the cache of a page that contains a query not the query itself so the first user that visits the page will trigger the re-computation.

Title::invalidateCache only updates page_touched while doPurge would trigger a complete null edit. Self-reference queries are a bit tricky (https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1696).

Up to now I thought "subject" and "page" were synonym, but maybe not?

It depends on the context, whether the subject in itself only represents an object value or is an entity.