jenkins-bot has submitted this change and it was merged. Change subject: Remove direct echo db access from mobilefrontend ......................................................................
Remove direct echo db access from mobilefrontend This revives https://gerrit.wikimedia.org/r/#/c/155663/, it's reverted earlier because Echo was not being stable, it's safe now as the Echo code has been deployed to both deployment branches Change-Id: I036606a0a706ea898838a36ef92c1a1e658c0a9a --- M includes/MobileUserInfo.php 1 file changed, 11 insertions(+), 16 deletions(-) Approvals: MaxSem: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/MobileUserInfo.php b/includes/MobileUserInfo.php index 520c7ad..5d9bd5e 100644 --- a/includes/MobileUserInfo.php +++ b/includes/MobileUserInfo.php @@ -168,23 +168,18 @@ $thank = false; // Check that the Thank Extension and Echo extension are both installed // before doing this (bug 56825). - if ( class_exists( 'MWEchoDbFactory' ) && class_exists( 'ApiThank' ) ) { - $dbr = MWEchoDbFactory::getDB( DB_SLAVE ); - $rows = $dbr->select( - array( 'echo_event', 'echo_notification' ), - 'event_agent_id, notification_timestamp', - array( - 'notification_user' => $this->user->getId(), - 'event_id=notification_event', - 'event_type' => 'edit-thank' ), - __METHOD__, - array( 'ORDER BY' => 'notification_timestamp DESC' ) + if ( class_exists( 'EchoNotificationMapper' ) && class_exists( 'ApiThank' ) ) { + // @FIXME - Inject the instance into the class for unittest? + $mapper = new EchoNotificationMapper(); + $notifs = $mapper->fetchByUser( + $this->user, 1, null, array( 'edit-thank' ) ); - $row = $rows->fetchObject(); - if ( $row ) { - $thank = array( - 'user' => User::newFromId( $row->event_agent_id ), - ); + if ( $notifs ) { + $notif = reset( $notifs ); + $agent = $notif->getEvent()->getAgent(); + if ( $agent ) { + $thank = array( 'user' => $agent ); + } } } wfProfileOut( __METHOD__ ); -- To view, visit https://gerrit.wikimedia.org/r/160159 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I036606a0a706ea898838a36ef92c1a1e658c0a9a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Bsitu <[email protected]> Gerrit-Reviewer: Awjrichards <[email protected]> Gerrit-Reviewer: JGonera <[email protected]> Gerrit-Reviewer: MaxSem <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
