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
This commit is contained in:
parent
e227752be6
commit
d88d902735
1 changed files with 34 additions and 3 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue