Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/276062
Change subject: Revert "Defer onPersonalUrls() DB writes to post-send" ...................................................................... Revert "Defer onPersonalUrls() DB writes to post-send" Causes fatals in production for some reason. This reverts commit 93387806c2674bb678d970a7748f9c225150830b. Bug: T129299 Change-Id: Ie90aa493e2940fae9d6f380b95f87a4cc7e04622 (cherry picked from commit e372f3ce6f3b7be3bf6b926feb1c93b55ef6c72e) --- M Hooks.php M includes/mapper/TargetPageMapper.php M includes/model/TargetPage.php 3 files changed, 13 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/62/276062/1 diff --git a/Hooks.php b/Hooks.php index 7d51ae3..b326795 100644 --- a/Hooks.php +++ b/Hooks.php @@ -724,40 +724,24 @@ return true; } - // Attempt to mark a notification as read when visiting a page - // @todo should this really be here? - $subtractAlerts = 0; - $subtractMessages = 0; + // Attempt to mark a notification as read when visiting a page, + // ideally this should be deferred to end of request and update + // the notification count accordingly + // @Fixme - Find a better place to put this code if ( $title->getArticleID() ) { $mapper = new EchoTargetPageMapper(); $targetPages = $mapper->fetchByUserPageId( $user, $title->getArticleID() ); if ( $targetPages ) { - $eventIds = array(); - $attribManager = EchoAttributeManager::newFromGlobalVars(); - /* @var EchoTargetPage $targetPage */ - foreach ( $targetPages as $id => $targetPage ) { - $section = $attribManager->getNotificationSection( - $targetPage->getEventType() - ); - if ( $section === EchoAttributeManager::MESSAGE ) { - $subtractMessages += 1; - } else { - // ALERT - $subtractAlerts += 1; - } - $eventIds[] = $id; - } - DeferredUpdates::addCallableUpdate( function () use ( $user, $eventIds ) { - $notifUser = MWEchoNotifUser::newFromUser( $user ); - $notifUser->markRead( $eventIds ); - } ); + $eventIds = array_keys( $targetPages ); + $notifUser = MWEchoNotifUser::newFromUser( $user ); + $notifUser->markRead( $eventIds ); } } // Add a "My notifications" item to personal URLs $notifUser = MWEchoNotifUser::newFromUser( $user ); - $msgCount = $notifUser->getMessageCount() - $subtractMessages; - $alertCount = $notifUser->getAlertCount() - $subtractAlerts; + $msgCount = $notifUser->getMessageCount(); + $alertCount = $notifUser->getAlertCount(); $msgNotificationTimestamp = $notifUser->getLastUnreadMessageTime(); $alertNotificationTimestamp = $notifUser->getLastUnreadAlertTime(); diff --git a/includes/mapper/TargetPageMapper.php b/includes/mapper/TargetPageMapper.php index 7cdfde9..f34803a 100644 --- a/includes/mapper/TargetPageMapper.php +++ b/includes/mapper/TargetPageMapper.php @@ -28,15 +28,13 @@ $dbr = $this->dbFactory->getEchoDb( DB_SLAVE ); $res = $dbr->select( - array( 'echo_target_page', 'echo_event' ), - array_merge( self::$fields, array( 'event_type' ) ), + array( 'echo_target_page' ), + self::$fields, array( 'etp_user' => $user->getId(), 'etp_page' => $pageId ), - __METHOD__, - array(), - array( 'echo_event' => array( 'JOIN', 'etp_event=event_id' ) ) + __METHOD__ ); if ( $res ) { $targetPages = array(); diff --git a/includes/model/TargetPage.php b/includes/model/TargetPage.php index c678947..dbdc414 100644 --- a/includes/model/TargetPage.php +++ b/includes/model/TargetPage.php @@ -33,11 +33,6 @@ protected $eventId; /** - * @var string - */ - protected $eventType; - - /** * Only allow creating instance internally */ protected function __construct() { @@ -49,7 +44,7 @@ * @param User $user * @param Title $title * @param EchoEvent $event - * @return EchoTargetPage|null + * @return TargetPage|null */ public static function create( User $user, Title $title, EchoEvent $event ) { // This only support title with a page_id @@ -60,7 +55,6 @@ $obj->user = $user; $obj->event = $event; $obj->eventId = $event->getId(); - $obj->eventType = $event->getType(); $obj->title = $title; $obj->pageId = $title->getArticleID(); @@ -89,9 +83,6 @@ $obj->user = User::newFromId( $row->etp_user ); $obj->pageId = $row->etp_page; $obj->eventId = $row->etp_event; - if ( isset( $row->event_type ) ) { - $obj->eventType = $row->event_type; - } return $obj; } @@ -137,17 +128,6 @@ */ public function getEventId() { return $this->eventId; - } - - /** - * @return string - */ - public function getEventType() { - if ( !$this->eventType ) { - $this->eventType = $this->getEvent()->getType(); - } - - return $this->eventType; } /** -- To view, visit https://gerrit.wikimedia.org/r/276062 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie90aa493e2940fae9d6f380b95f87a4cc7e04622 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: wmf/1.27.0-wmf.16 Gerrit-Owner: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits