Skip to content

Commit 655e9e7

Browse files
author
Alexander Gesinn
committed
use hook registration via extension.json, prepared 2.0.0-alpha, now requires SMW 3.1+, MW 1.31+
1 parent 0c6d9e2 commit 655e9e7

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

Diff for: SemanticDependencyUpdater.hooks.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@
1313
class Hooks {
1414

1515
public static function setup() {
16-
1716
if ( !defined( 'MEDIAWIKI' ) ) {
1817
die();
1918
}
2019

2120
if ( !defined( 'SMW_VERSION' ) ) {
2221
die( "ERROR: Semantic MediaWiki must be installed for Semantic Dependency Updater to run!" );
2322
}
24-
25-
global $wgHooks;
26-
// registered Hook this way to make sure SMW is loaded
27-
$wgHooks['SMW::SQLStore::AfterDataUpdateComplete'][] = 'SDU\Hooks::onAfterDataUpdateComplete';
2823
}
2924

3025
public static function onAfterDataUpdateComplete( SMWStore $store, SMWSemanticData $newData,
@@ -44,15 +39,16 @@ public static function onAfterDataUpdateComplete( SMWStore $store, SMWSemanticDa
4439
wfDebugLog( 'SemanticDependencyUpdater', "[SDU] --> " . $title );
4540

4641

47-
// FIRST CHECK: Does the page data contain a $wgSUTPropertyName semantic property ?
42+
// FIRST CHECK: Does the page data contain a $wgSDUProperty semantic property ?
4843
$properties = $newData->getProperties();
49-
$diffTable = $compositePropertyTableDiffIterator->getOrderedDiffByTable();
50-
5144
if ( !isset( $properties[$wgSDUProperty] ) ) {
5245
wfDebugLog( 'SemanticDependencyUpdater', "[SDU] <-- No SDU property found" );
5346
return true;
5447
}
5548

49+
$diffTable = $compositePropertyTableDiffIterator->getOrderedDiffByTable();
50+
51+
5652
// SECOND CHECK: Have there been actual changes in the data? (Ignore internal SMW data!)
5753
// TODO: Introduce an explicit list of Semantic Properties to watch ?
5854
unset( $diffTable['smw_fpt_mdat'] ); // Ignore SMW's internal properties "smw_fpt_mdat"
@@ -68,7 +64,7 @@ public static function onAfterDataUpdateComplete( SMWStore $store, SMWSemanticDa
6864

6965
// THIRD CHECK: Has this page been already traversed more than twice?
7066
// This should only be the case when SMW errors occur.
71-
// In that case, the diffTable contains everything and SDU can't know if changes happend
67+
// In that case, the diffTable contains everything and SDU can't know if changes happened
7268
if ( array_key_exists( $id, $wgSDUTraversed ) ) {
7369
$wgSDUTraversed[$id] = $wgSDUTraversed[$id] + 1;
7470
} else {
@@ -82,6 +78,8 @@ public static function onAfterDataUpdateComplete( SMWStore $store, SMWSemanticDa
8278

8379
// QUERY AND UPDATE DEPENDENCIES
8480

81+
// SMW\SemanticData $newData
82+
// SMWDataItem[] $dataItem
8583
$dataItem = $newData->getPropertyValues( $properties[$wgSDUProperty] );
8684

8785
if ( $dataItem != null ) {

Diff for: extension.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SemanticDependencyUpdater",
3-
"version": "1.4.1",
3+
"version": "2.0.0-alpha",
44
"author": [
55
"Simon Heimler (gesinn.it GmbH & Co. KG)",
66
"Alexander Gesinn (gesinn.it GmbH & Co. KG)",
@@ -12,21 +12,24 @@
1212
"license-name": "MIT",
1313
"type": "semantic",
1414
"requires": {
15-
"MediaWiki": ">= 1.25",
15+
"MediaWiki": ">= 1.31",
1616
"extensions": {
17-
"SemanticMediaWiki": ">= 2.3.0"
17+
"SemanticMediaWiki": ">= 3.1.0"
1818
}
1919
},
2020
"AutoloadClasses": {
2121
"SDU\\Hooks": "SemanticDependencyUpdater.hooks.php",
2222
"SDU\\DummyEditJob": "includes/DummyEditJob.php"
2323
},
24+
"Hooks": {
25+
"SMW::SQLStore::AfterDataUpdateComplete": [
26+
"SDU\\Hooks::onAfterDataUpdateComplete"
27+
]
28+
},
2429
"JobClasses": {
2530
"SDU\\DummyEditJob": "DummyEditJob"
2631
},
27-
"ExtensionFunctions": [
28-
"SDU\\Hooks::setup"
29-
],
32+
"callback": "SDU\\Hooks::setup",
3033
"config": {
3134
"SDUProperty": "Semantic Dependency",
3235
"SDUUseJobQueue": false

0 commit comments

Comments
 (0)