Bsitu has uploaded a new change for review.
https://gerrit.wikimedia.org/r/155663
Change subject: Remove direct echo db access from mobilefrontend
......................................................................
Remove direct echo db access from mobilefrontend
* It should just use the database access object in Echo
* Since it only needs the latest thank record, it should just
query 1 instead of querying all and getting the first one
This is not tested, not sure how to test it
Change-Id: If5201bb9a81a7c5e9e643ee1ad239248b0663caa
---
M includes/MobileUserInfo.php
1 file changed, 14 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/63/155663/1
diff --git a/includes/MobileUserInfo.php b/includes/MobileUserInfo.php
index 520c7ad..9be4466 100644
--- a/includes/MobileUserInfo.php
+++ b/includes/MobileUserInfo.php
@@ -168,23 +168,21 @@
$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' ) ) {
+ // @Todo - Inject the instance into the class for
unittest?
+ $mapper = new EchoNotificationMapper();
+ $notifs = $mapper->fetchByUser(
+ /*$user=*/$this->user,
+ /*$limit=*/1,
+ /*$continue=*/null,
+ /*$eventTypes=*/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/155663
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If5201bb9a81a7c5e9e643ee1ad239248b0663caa
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