SemanticDataComparator tries to detect whether a SG related property was exposed to an alteration and if so invalidated the cache. Executing SemanticDataComparator can be quite expensive and to avoid this, SMW 2.3 exposes CompositePropertyTableDiffIterator which contains the diff of inserted or deleted values.
The following change would do the same:
- /**
- * Invalidate on update
- *
- * @since 1.0
- */
- $this->handlers['SMWStore::updateDataBefore'] = function ( $store, $semanticData ) {
- return \SG\Cache\CacheInvalidator::getInstance()->invalidateCacheOnStoreUpdate( $store, $semanticData );
+ $this->handlers['SMW::SQLStore::AfterDataUpdateComplete'] = function ( $store, $semanticData, $compositePropertyTableDiffIterator ) {
+
+ $hasChanged = false;
+
+ $mapCombinedIdListOfChangedEntities = array_flip(
+ $compositePropertyTableDiffIterator->getCombinedIdListOfChangedEntities()
+ );
+
+ foreach ( array( PropertyRegistry::SG_TERM, PropertyRegistry::SG_DEFINITION, PropertyRegistry::SG_LINK, PropertyRegistry::SG_STYLE ) as $property ) {
+ $id = $store->getObjectIds()->getSMWPropertyID(
+ new \SMW\DIProperty( $property )
+ );
+
+ if ( isset( $mapCombinedIdListOfChangedEntities[$id] ) ) {
+ $hasChanged = true;
+ break;
+ }
+ }
+
+ if ( $hasChanged ) {
+ \SG\Cache\CacheInvalidator::getInstance()->invalidateCacheOnPageDelete(
+ $store,
+ $semanticData->getSubject()
+ );
+
+ wfDebugLog( 'smw', 'Run SG CacheInvalidator on ' . $semanticData->getSubject()->getHash() );
+ }
+
+ return true;
};
SemanticDataComparatortries to detect whether a SG related property was exposed to an alteration and if so invalidated the cache. ExecutingSemanticDataComparatorcan be quite expensive and to avoid this, SMW 2.3 exposesCompositePropertyTableDiffIteratorwhich contains the diff of inserted or deleted values.The following change would do the same: