jenkins-bot has submitted this change and it was merged.
Change subject: Comparing User objects is unreliable
......................................................................
Comparing User objects is unreliable
Objects can be different instances (and for User, they can contain
very different data) in which case they wouldn't be recognized even
if they were the same user.
Let's find by ID instead.
Bug: T124803
Change-Id: Ia166fd4190f264354cea83d98047c62c7e0714ea
---
M includes/controller/NotificationController.php
1 file changed, 8 insertions(+), 2 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/controller/NotificationController.php
b/includes/controller/NotificationController.php
index eb63f37..8ac744b 100644
--- a/includes/controller/NotificationController.php
+++ b/includes/controller/NotificationController.php
@@ -311,8 +311,14 @@
foreach ( self::evaluateUserCallable( $event,
EchoAttributeManager::ATTR_FILTERS ) as $users ) {
// the result of the callback can be both an iterator
or array
$users = is_array( $users ) ? $users :
iterator_to_array( $users );
- $notify->addFilter( function ( $user ) use ( $users ) {
- return !in_array( $user, $users );
+ $notify->addFilter( function ( User $user ) use (
$users ) {
+ // we need to check if $user is in $users, but
they're not
+ // guaranteed to be the same object, so I'll
compare ids.
+ $userId = $user->getId();
+ $userIds = array_map( function ( User $user ) {
+ return $user->getId();
+ }, $users );
+ return !in_array( $userId, $userIds );
} );
}
--
To view, visit https://gerrit.wikimedia.org/r/269958
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia166fd4190f264354cea83d98047c62c7e0714ea
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits