jenkins-bot has submitted this change and it was merged.
Change subject: Remove WikibaseEntityInsertionUpdate hook
......................................................................
Remove WikibaseEntityInsertionUpdate hook
WikibaseEntityModificationUpdate was never executed. Instead, every edit
triggered WikibaseEntityInsertionUpdate. Now, WikibaseEntityModificationUpdate
is triggered for every edit.
The old content passed to new ItemModificationUpdate objects was always null
since getSecondaryDataUpdates right now never gets passed an old content.
Change-Id: I7ad18d3e2b536480d0b23c5f48f1a3e9b028c4f8
---
M repo/includes/content/ItemContent.php
M repo/includes/content/PropertyContent.php
M repo/includes/updates/EntityModificationUpdate.php
M repo/includes/updates/ItemModificationUpdate.php
M repo/tests/phpunit/includes/updates/ItemModificationUpdateTest.php
5 files changed, 20 insertions(+), 45 deletions(-)
Approvals:
WikidataJenkins: Verified
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/includes/content/ItemContent.php
b/repo/includes/content/ItemContent.php
index 8d2a62b..d1875d1 100644
--- a/repo/includes/content/ItemContent.php
+++ b/repo/includes/content/ItemContent.php
@@ -276,14 +276,14 @@
* @param bool $recursive
* @param null|ParserOutput $parserOutput
*
- * @return \Title of DataUpdate
+ * @return DataUpdate[]
*/
public function getSecondaryDataUpdates( Title $title, Content $old =
null,
$recursive = false, ParserOutput $parserOutput = null ) {
return array_merge(
parent::getSecondaryDataUpdates( $title, $old,
$recursive, $parserOutput ),
- array( new ItemModificationUpdate( $this, $old ) )
+ array( new ItemModificationUpdate( $this ) )
);
}
diff --git a/repo/includes/content/PropertyContent.php
b/repo/includes/content/PropertyContent.php
index d6db600..1d37789 100644
--- a/repo/includes/content/PropertyContent.php
+++ b/repo/includes/content/PropertyContent.php
@@ -192,7 +192,7 @@
return array_merge(
parent::getSecondaryDataUpdates( $title, $old,
$recursive, $parserOutput ),
array(
- new EntityModificationUpdate( $this, $old ),
+ new EntityModificationUpdate( $this ),
new PropertyInfoUpdate( $this->getProperty(),
$infoStore ),
)
);
diff --git a/repo/includes/updates/EntityModificationUpdate.php
b/repo/includes/updates/EntityModificationUpdate.php
index 3155f85..a5b2c16 100644
--- a/repo/includes/updates/EntityModificationUpdate.php
+++ b/repo/includes/updates/EntityModificationUpdate.php
@@ -21,23 +21,14 @@
protected $newContent;
/**
- * @since 0.5
- *
- * @var null|EntityContent
- */
- protected $oldContent;
-
- /**
* Constructor.
*
* @since 0.1
*
* @param EntityContent $newContent
- * @param EntityContent|null $oldContent
*/
- public function __construct( EntityContent $newContent, EntityContent
$oldContent = null ) {
+ public function __construct( EntityContent $newContent ) {
$this->newContent = $newContent;
- $this->oldContent = $oldContent;
}
/**
@@ -49,7 +40,7 @@
wfProfileIn( __METHOD__ );
$this->updateRepoStore();
- $this->fireHooks();
+ $this->fireHook();
wfProfileOut( __METHOD__ );
}
@@ -74,32 +65,7 @@
// Override to add behavior.
}
- protected function fireHooks() {
- if ( $this->isInsertionUpdate() ) {
- $this->firstInsertionHook();
- }
- else {
- $this->fireModificationHook();
- }
- }
-
- protected function isInsertionUpdate() {
- return $this->oldContent === null;
- }
-
- protected function firstInsertionHook() {
- /**
- * Gets called after the structured save of an item has been
committed,
- * allowing for extensions to do additional storage/indexing.
- *
- * @since 0.5
- *
- * @param EntityContent $entityContent
- */
- wfRunHooks( 'WikibaseEntityInsertionUpdate', array(
$this->newContent ) );
- }
-
- protected function fireModificationHook() {
+ protected function fireHook() {
/**
* Gets called after the structured save of an item has been
committed,
* allowing for extensions to do additional storage/indexing.
@@ -107,9 +73,8 @@
* @since 0.5
*
* @param EntityContent $newEntityContent
- * @param EntityContent $oldEntityContent
*/
- wfRunHooks( 'WikibaseEntityModificationUpdate', array(
$this->newContent, $this->oldContent ) );
+ wfRunHooks( 'WikibaseEntityModificationUpdate', array(
$this->newContent ) );
}
}
diff --git a/repo/includes/updates/ItemModificationUpdate.php
b/repo/includes/updates/ItemModificationUpdate.php
index 633eb82..7ed0a35 100644
--- a/repo/includes/updates/ItemModificationUpdate.php
+++ b/repo/includes/updates/ItemModificationUpdate.php
@@ -19,10 +19,9 @@
* @since 0.1
*
* @param ItemContent $newContent
- * @param null|ItemContent $oldContent
*/
- public function __construct( ItemContent $newContent, ItemContent
$oldContent = null ) {
- parent::__construct( $newContent, $oldContent );
+ public function __construct( ItemContent $newContent ) {
+ parent::__construct( $newContent );
}
/**
diff --git a/repo/tests/phpunit/includes/updates/ItemModificationUpdateTest.php
b/repo/tests/phpunit/includes/updates/ItemModificationUpdateTest.php
index 1b16816..f524d2a 100644
--- a/repo/tests/phpunit/includes/updates/ItemModificationUpdateTest.php
+++ b/repo/tests/phpunit/includes/updates/ItemModificationUpdateTest.php
@@ -55,6 +55,12 @@
$revision = $store->saveEntity( $itemContent->getEntity(),
"testing", $GLOBALS['wgUser'], EDIT_NEW );
$id = $revision->getEntity()->getId()->getNumericId();
+ $this->stashMwGlobals( 'wgHooks' );
+ $hookCalled = false;
+ $GLOBALS['wgHooks']['WikibaseEntityModificationUpdate'][] =
function () use ( &$hookCalled ) {
+ $hookCalled = true;
+ };
+
$update = new ItemModificationUpdate( $itemContent );
$update->doUpdate();
@@ -68,6 +74,11 @@
$actual
);
+ $this->assertTrue(
+ $hookCalled,
+ 'Assert hook WikibaseEntityModificationUpdate was
called'
+ );
+
// TODO: verify terms
$update = new ItemDeletionUpdate( $itemContent );
--
To view, visit https://gerrit.wikimedia.org/r/125976
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ad18d3e2b536480d0b23c5f48f1a3e9b028c4f8
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: WikidataJenkins <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits