Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/392066 )

Change subject: Only schedule job if constraint statements were edited
......................................................................

Only schedule job if constraint statements were edited

Now that we have a compact entity diff in the change, including the
property IDs of affected statements, we can finally only schedule the
updater job when it’s actually necessary.

Tested manually by doing various edits on a property and running the
following command after each edit:

    php maintenance/runJobs.php | grep constraintsTableUpdate

There should only be output after edits that actually changed the
constraint statements.

Change-Id: I37a0df0e10174f40f66e4afc6865f6e1d481d129
Depends-On: I1864f91de8ae5b1ba228fecc534db740bf2aefe9
---
M WikibaseQualityConstraintsHooks.php
1 file changed, 11 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/66/392066/1

diff --git a/WikibaseQualityConstraintsHooks.php 
b/WikibaseQualityConstraintsHooks.php
index 948e281..6e17fad 100644
--- a/WikibaseQualityConstraintsHooks.php
+++ b/WikibaseQualityConstraintsHooks.php
@@ -11,6 +11,7 @@
 use Wikibase\EntityChange;
 use Wikibase\DataModel\Entity\PropertyId;
 use Wikibase\DataModel\Services\Diff\EntityDiff;
+use Wikibase\Lib\Changes\EntityDiffChangedAspects;
 
 /**
  * Container for hook callbacks registered in extension.json.
@@ -60,12 +61,19 @@
                }
 
                $diff = $change->getDiff();
-               if ( !( $diff instanceof EntityDiff ) ) {
+
+               if ( $diff instanceof EntityDiff ) {
+                       // minimized diff, cannot be used to check if 
constraint statements changed
+                       return true;
+               }
+
+               if ( !( $diff instanceof EntityDiffChangedAspects ) ) {
                        return false;
                }
 
-               // TODO inspect the diff once T113468 or T163465 are resolved
-               return true;
+               $propertyConstraintId = 
MediaWikiServices::getInstance()->getMainConfig()
+                       ->get( 'WBQualityConstraintsPropertyConstraintId' );
+               return in_array( $propertyConstraintId, 
$diff->getStatementChanges() );
        }
 
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/392066
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I37a0df0e10174f40f66e4afc6865f6e1d481d129
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to