Extension:SemanticDependencyUpdater

The Semantic Dependency Updater (SDU) extension monitors pages for changes in their semantic data. If the "Semantic Dependency" property is found, this extension will update (null-edit) all pages that have been selected through that property. A common use case is change propagation where pages needs to update (pull) their semantic data via an ask query from a changed page.

The "Semantic Dependency property" is evaluated as an ASK query. It is therefore possible to define either a list of pages directly or do more complex selections.

Installation
Instead of downloading the zip archive you may also check this extension out via Git:

Mandatory
Make sure, a "Semantic Dependency" property exists, e.g. "Property:Semantic_Dependency" needs to exist and MUST be of the datatype :

Has type::Text

Usage
The value of the Semantic Dependency property is evaluated as an ASK query, except that  or   must be ommitted. If there are more conditions, combine them through  and

Update Self
This will save the current page twice. Useful when the page stores semantic properties that are calculated from other properties of the same page.

Semantic Dependency::

Update other page(s)
Semantic Dependency::Product:Test Product Semantic Dependency::

Update pages with relation to current page
This will update all pages that link with  to the current page. Semantic Dependency::Part Of::

More Advanced Queries
Be careful that the query does not return too many pages, as this will result in a heavy load. Semantic Dependency::Category:Product Semantic Dependency::Category:Product AND Tag::Demo Semantic Dependency::Category:Person OR Category:Organization

Example test case

 * Make sure, a page  exists with content
 * Make sure,
 * Create a page  with

Title::A


 * Create a page  with
 * Title::.B


 * Now, change page  as follows

Title::XXX

As a result, you should see - XXX.B - XXX.B on page

Debugging
> mkdir /var/log/mediawiki > chmod -R www-data. /var/log/mediawiki $wgDebugLogGroups['SemanticDependencyUpdater'] = '/var/log/mediawiki/SDU.log'; > tail -f /var/log/mediawiki/SDU.log 2020-03-25 13:01:45 vagrant wikidb01-wk: [SDU] --> A 2020-03-25 13:01:45 vagrant wikidb01-wk: [SDU] -> Data changes detected 2020-03-25 13:01:45 vagrant wikidb01-wk: [SDU] > Part Of::A 2020-03-25 13:01:45 vagrant wikidb01-wk: [SDU] > [Edit] B
 * Note, that on some systems logging to /tmp might not work
 * Make sure, a log folder, writable by your web server, exists
 * In your LocalSettings enable
 * Watch the log file
 * If things work as expected, this will look like: