13
13
class Hooks {
14
14
15
15
public static function setup () {
16
-
17
16
if ( !defined ( 'MEDIAWIKI ' ) ) {
18
17
die ();
19
18
}
20
19
21
20
if ( !defined ( 'SMW_VERSION ' ) ) {
22
21
die ( "ERROR: Semantic MediaWiki must be installed for Semantic Dependency Updater to run! " );
23
22
}
24
-
25
- global $ wgHooks ;
26
- // registered Hook this way to make sure SMW is loaded
27
- $ wgHooks ['SMW::SQLStore::AfterDataUpdateComplete ' ][] = 'SDU\Hooks::onAfterDataUpdateComplete ' ;
28
23
}
29
24
30
25
public static function onAfterDataUpdateComplete ( SMWStore $ store , SMWSemanticData $ newData ,
@@ -44,15 +39,16 @@ public static function onAfterDataUpdateComplete( SMWStore $store, SMWSemanticDa
44
39
wfDebugLog ( 'SemanticDependencyUpdater ' , "[SDU] --> " . $ title );
45
40
46
41
47
- // FIRST CHECK: Does the page data contain a $wgSUTPropertyName semantic property ?
42
+ // FIRST CHECK: Does the page data contain a $wgSDUProperty semantic property ?
48
43
$ properties = $ newData ->getProperties ();
49
- $ diffTable = $ compositePropertyTableDiffIterator ->getOrderedDiffByTable ();
50
-
51
44
if ( !isset ( $ properties [$ wgSDUProperty ] ) ) {
52
45
wfDebugLog ( 'SemanticDependencyUpdater ' , "[SDU] <-- No SDU property found " );
53
46
return true ;
54
47
}
55
48
49
+ $ diffTable = $ compositePropertyTableDiffIterator ->getOrderedDiffByTable ();
50
+
51
+
56
52
// SECOND CHECK: Have there been actual changes in the data? (Ignore internal SMW data!)
57
53
// TODO: Introduce an explicit list of Semantic Properties to watch ?
58
54
unset( $ diffTable ['smw_fpt_mdat ' ] ); // Ignore SMW's internal properties "smw_fpt_mdat"
@@ -68,7 +64,7 @@ public static function onAfterDataUpdateComplete( SMWStore $store, SMWSemanticDa
68
64
69
65
// THIRD CHECK: Has this page been already traversed more than twice?
70
66
// 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
72
68
if ( array_key_exists ( $ id , $ wgSDUTraversed ) ) {
73
69
$ wgSDUTraversed [$ id ] = $ wgSDUTraversed [$ id ] + 1 ;
74
70
} else {
@@ -82,6 +78,8 @@ public static function onAfterDataUpdateComplete( SMWStore $store, SMWSemanticDa
82
78
83
79
// QUERY AND UPDATE DEPENDENCIES
84
80
81
+ // SMW\SemanticData $newData
82
+ // SMWDataItem[] $dataItem
85
83
$ dataItem = $ newData ->getPropertyValues ( $ properties [$ wgSDUProperty ] );
86
84
87
85
if ( $ dataItem != null ) {
0 commit comments