Thiemo Mättig (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/337794 )
Change subject: Fix bad type casting in ChangeHandler related code in client
......................................................................
Fix bad type casting in ChangeHandler related code in client
I followed all code paths and this is what happens: These objects are
always created as EntityChange objects. Then the code forgets about this
and passes them around as Change objects. But later the code assumes all
these objects are EntityChange objects.
I might miss something, but I can't think of an other fix. I remember
looking into this specific type safety warning many, many times and I'm
actually very happe with this patch, because it finally solves it! \o/
Change-Id: I1334bca286e6cb52cdfaba61d0ce171509b892d5
---
M client/includes/ChangeNotificationJob.php
M client/includes/Changes/ChangeHandler.php
M client/includes/Changes/ChangeListTransformer.php
M client/includes/Changes/ChangeRunCoalescer.php
4 files changed, 10 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/94/337794/1
diff --git a/client/includes/ChangeNotificationJob.php
b/client/includes/ChangeNotificationJob.php
index 6dd1b19..a6f4ffb 100644
--- a/client/includes/ChangeNotificationJob.php
+++ b/client/includes/ChangeNotificationJob.php
@@ -17,7 +17,7 @@
class ChangeNotificationJob extends Job {
/**
- * @var Change[]|null Initialized lazily by getChanges.
+ * @var EntityChange[]|null Initialized lazily by getChanges.
*/
private $changes = null;
@@ -59,7 +59,7 @@
*
* EntityChange objects are loaded using a EntityChangeLookup.
*
- * @return Change[] the changes to process.
+ * @return EntityChange[] the changes to process.
*/
private function getChanges() {
if ( $this->changes === null ) {
diff --git a/client/includes/Changes/ChangeHandler.php
b/client/includes/Changes/ChangeHandler.php
index 5a770c5..86320a4 100644
--- a/client/includes/Changes/ChangeHandler.php
+++ b/client/includes/Changes/ChangeHandler.php
@@ -118,9 +118,7 @@
}
/**
- * Handle the provided changes.
- *
- * @param Change[] $changes
+ * @param EntityChange[] $changes
*/
public function handleChanges( array $changes ) {
$changes = $this->changeListTransformer->transformChangeList(
$changes );
@@ -143,11 +141,11 @@
*
* @todo: process multiple changes at once!
*
- * @param Change $change
+ * @param EntityChange $change
*
* @throws MWException
*/
- public function handleChange( Change $change ) {
+ public function handleChange( EntityChange $change ) {
$changeId = $this->getChangeIdForLog( $change );
wfDebugLog( __CLASS__, __FUNCTION__ . ": handling change
#$changeId"
. ' (' . $change->getType() . ')' );
diff --git a/client/includes/Changes/ChangeListTransformer.php
b/client/includes/Changes/ChangeListTransformer.php
index 3e41998..fa44739 100644
--- a/client/includes/Changes/ChangeListTransformer.php
+++ b/client/includes/Changes/ChangeListTransformer.php
@@ -2,7 +2,7 @@
namespace Wikibase\Client\Changes;
-use Wikibase\Change;
+use Wikibase\EntityChange;
/**
* Interface for service objects implementing some transformation on a list of
Change objects.
@@ -16,9 +16,9 @@
* Processes the given list of changes, possibly merging, filtering or
otherwise modifying
* changes and/or the list of changes.
*
- * @param Change[] $changes
+ * @param EntityChange[] $changes
*
- * @return Change[]
+ * @return EntityChange[]
*/
public function transformChangeList( array $changes );
diff --git a/client/includes/Changes/ChangeRunCoalescer.php
b/client/includes/Changes/ChangeRunCoalescer.php
index 5195404..4cf213b 100644
--- a/client/includes/Changes/ChangeRunCoalescer.php
+++ b/client/includes/Changes/ChangeRunCoalescer.php
@@ -56,9 +56,9 @@
* Processes the given list of changes, combining any runs of changes
into a single change.
* See the class level documentation for more details on change runs.
*
- * @param Change[] $changes
+ * @param EntityChange[] $changes
*
- * @return Change[]
+ * @return EntityChange[]
*/
public function transformChangeList( array $changes ) {
$coalesced = array();
--
To view, visit https://gerrit.wikimedia.org/r/337794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1334bca286e6cb52cdfaba61d0ce171509b892d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits