Aude has uploaded a new change for review.
https://gerrit.wikimedia.org/r/188224
Change subject: Check for empty arrays in UsageUpdater
......................................................................
Check for empty arrays in UsageUpdater
(follow-up to I8d52312)
if the list of unused / removed entities is empty,
but added is not empty then the code should still
skip the unsubscribe call, which lead (until I8d52312)
to a database error if using SqlSubscriptionManager.
There still should be a check there, but we can avoid a
bunch of processing by having check here also.
Bug: T88329
Change-Id: Ia2a47e03b8bd10c923a0a911d24541de03aaea8d
---
M client/includes/store/UsageUpdater.php
1 file changed, 18 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/24/188224/1
diff --git a/client/includes/store/UsageUpdater.php
b/client/includes/store/UsageUpdater.php
index b795d49..acf5a03 100644
--- a/client/includes/store/UsageUpdater.php
+++ b/client/includes/store/UsageUpdater.php
@@ -80,20 +80,28 @@
$added = array_diff_key( $currentlyUsedEntities,
$previouslyUsedEntities );
$removed = array_diff_key( $previouslyUsedEntities,
$currentlyUsedEntities );
- if ( empty( $added ) && empty( $removed ) ) {
- return;
+ // Subscribe to anything that was added
+ if ( !empty( $added ) ) {
+ $this->subscriptionManager->subscribe( $this->clientId,
$added );
}
- $unused = $this->usageLookup->getUnusedEntities( $removed );
+ $this->unsubscribeUnused( $removed );
+ }
- if ( empty( $added ) && empty( $unused ) ) {
- return;
+ /**
+ * Unsubscribe from anything that was removed and is otherwise unused.
+ *
+ * @param EntityId[] $removedIds
+ */
+ private function unsubscribeUnused( array $removedIds ) {
+ if ( !empty( $removedIds ) ) {
+ $unusedIds = $this->usageLookup->getUnusedEntities(
$removedIds );
+
+ if ( !empty( $unusedIds ) ) {
+ // Unsubscribe from anything that was removed
and is otherwise unused.
+ $this->subscriptionManager->unsubscribe(
$this->clientId, $unusedIds );
+ }
}
-
- // Subscribe to anything that was added, unsubscribe from
anything
- // that was removed and is otherwise unused.
- $this->subscriptionManager->subscribe( $this->clientId, $added
);
- $this->subscriptionManager->unsubscribe( $this->clientId,
$unused );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/188224
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2a47e03b8bd10c923a0a911d24541de03aaea8d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits