From d88d902735ed17c6d9d0d8f00b6db2ff71f5fe07 Mon Sep 17 00:00:00 2001 From: cenarium Date: Thu, 28 Jan 2016 19:58:44 +0100 Subject: [PATCH] LinksUpdate: Add functions returning changed page properties This adds getAddedProperties and getRemovedProperties functions to LinksUpdate. They are available only after the update, so for extensions in the LinksUpdateComplete hook. This is useful for example if an extension caches a page property; if the property gets changed it may want to purge the cache. This is similar to the getAddedLinks and getRemovedLinks functions. Change-Id: I0c73b3d181f32502da75687857ae9aeff731f559 --- includes/deferred/LinksUpdate.php | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index 5e02c5cc6c..ec7360e0d9 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -79,6 +79,16 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate { */ private $linkDeletions = null; + /** + * @var null|array Added properties if calculated. + */ + private $propertyInsertions = null; + + /** + * @var null|array Deleted properties if calculated. + */ + private $propertyDeletions = null; + /** * @var User|null */ @@ -234,12 +244,13 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate { # Page properties $existing = $this->getExistingProperties(); - $propertiesDeletes = $this->getPropertyDeletions( $existing ); - $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes, + $this->propertyDeletions = $this->getPropertyDeletions( $existing ); + $this->incrTableUpdate( 'page_props', 'pp', $this->propertyDeletions, $this->getPropertyInsertions( $existing ) ); # Invalidate the necessary pages - $changed = $propertiesDeletes + array_diff_assoc( $this->mProperties, $existing ); + $this->propertyInsertions = array_diff_assoc( $this->mProperties, $existing ); + $changed = $this->propertyDeletions + $this->propertyInsertions; $this->invalidateProperties( $changed ); # Refresh links of all pages including this page @@ -1016,6 +1027,26 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate { return $result; } + /** + * Fetch page properties added by this LinksUpdate. + * Only available after the update is complete. + * @since 1.28 + * @return null|array + */ + public function getAddedProperties() { + return $this->propertyInsertions; + } + + /** + * Fetch page properties removed by this LinksUpdate. + * Only available after the update is complete. + * @since 1.28 + * @return null|array + */ + public function getRemovedProperties() { + return $this->propertyDeletions; + } + /** * Update links table freshness */ -- 2.20.1