Adrian Lang has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/125976

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
4 files changed, 9 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/76/125976/1

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 );
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ad18d3e2b536480d0b23c5f48f1a3e9b028c4f8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>

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

Reply via email to