Bsitu has uploaded a new change for review.

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

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/59/160159/1

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: newchange
Gerrit-Change-Id: I036606a0a706ea898838a36ef92c1a1e658c0a9a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>

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

Reply via email to