Mattflaschen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/231736
Change subject: Move edit-user-talk to messages
......................................................................
Move edit-user-talk to messages
Also:
* Clear the newtalk flag when they mark all their edit-user-talk
read.
* Remove the section caching system. It was designed to avoid
performance problems with Flow messages, but now that standard talk pages
are in 'messages', messages should be relatively common (alerts
were already not cached by this).
* Minor cleanups to reflect that messages are not only Flow (and
a typo fix in the Gruntfile)
Change-Id: I82d7b1d08331693830d6a1749612b55e96b95cf9
---
M Echo.php
M Gruntfile.js
M includes/NotifUser.php
M includes/api/ApiEchoNotifications.php
M includes/model/Notification.php
5 files changed, 15 insertions(+), 100 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/36/231736/1
diff --git a/Echo.php b/Echo.php
index 999650a..fe69f12 100644
--- a/Echo.php
+++ b/Echo.php
@@ -301,7 +301,7 @@
'secondary-link' => array( 'message' =>
'notification-link-text-view-changes', 'destination' => 'diff' ),
'category' => 'edit-user-talk',
'group' => 'interactive',
- 'section' => 'alert',
+ 'section' => 'message',
'bundle' => array( 'web' => true, 'email' => false ),
'formatter-class' => 'EchoEditUserTalkFormatter',
'title-message' => 'notification-edit-talk-page2',
diff --git a/Gruntfile.js b/Gruntfile.js
index 0f76c86..4fd276f 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,7 +1,7 @@
/*!
* Grunt file
*
- * @package Flow
+ * @package Echo
*/
/*jshint node:true */
diff --git a/includes/NotifUser.php b/includes/NotifUser.php
index 7e6c259..641d592 100644
--- a/includes/NotifUser.php
+++ b/includes/NotifUser.php
@@ -36,14 +36,6 @@
private $targetPageMapper;
/**
- * Whether to check cache for section status
- */
- static $sectionStatusCheckCache = array (
- EchoAttributeManager::ALERT => false,
- EchoAttributeManager::MESSAGE => true
- );
-
- /**
* Usually client code doesn't need to initialize the object directly
* because it could be obtained from factory method newFromUser()
* @param User $user
@@ -82,80 +74,6 @@
new EchoUserNotificationGateway( $user,
MWEchoDbFactory::newFromDefault() ),
new EchoNotificationMapper(),
new EchoTargetPageMapper()
- );
- }
-
- /**
- * Check whether should trigger a query to fetch data for a section
when making
- * such request. This method normally should return true for all
section.
- * For some sections, it's better to save the result in cache and check
before
- * triggering a query. Flow is in very limited deployment, Most *users
would
- * not have flow notifications, it's better to save *this status in
cache
- * to save a query. In addition, Flow notification is far less than
other
- * notifications for most users at this moment. Querying could be
expensive
- * in extreme cases
- * @param string $section
- * @return boolean
- */
- public function shouldQuerySectionData( $section ) {
- if ( !self::$sectionStatusCheckCache[$section] ) {
- return true;
- }
- $cacheVal = $this->cache->get( $this->sectionStatusCacheKey(
$section ) );
- // '1' means should query
- // '0' means should not query
- // false means no cache and should query
- if ( $cacheVal !== '0' ) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Set section data status into cache, '1' means there is data for the
section,
- * '0' means there is no data for this section
- * @param string $section
- * @param int $num
- */
- public function setSectionStatusCache( $section, $num ) {
- if ( !self::$sectionStatusCheckCache[$section] ) {
- return;
- }
- $key = $this->sectionStatusCacheKey( $section );
- // Set cache for 5 days
- if ( $num > 0 ) {
- $this->cache->set( $key, '1', 432000 );
- } else {
- $this->cache->set( $key, '0', 432000 );
- }
- }
-
- /**
- * Clear section data cache for the section
- * @param string
- */
- public function clearSectionStatusCache( $section ) {
- if ( !self::$sectionStatusCheckCache[$section] ) {
- return;
- }
- $this->cache->delete(
- $this->sectionStatusCacheKey( $section )
- );
- }
-
- /**
- * Get the section data status cache key
- * @param string $section
- * @return string
- */
- protected function sectionStatusCacheKey( $section ) {
- global $wgEchoConfig;
- return wfMemcKey(
- 'echo-notification-section-exist',
- $section,
- $this->mUser->getId(),
- $wgEchoConfig['version']
);
}
@@ -332,6 +250,15 @@
$this->targetPageMapper->deleteByUserEvents(
$this->mUser, $eventIds );
// Update notification count in cache
$this->resetNotificationCount( DB_MASTER );
+
+ // After this 'mark read', is there any unread
edit-user-talk
+ // remaining? If not, we should clear the newtalk flag.
+ if ( $this->mUser->getNewtalk() ) {
+ $unreadEditUserTalk =
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, array( 'edit-user-talk'
), DB_MASTER );
+ if ( count( $unreadEditUserTalk ) === 0 ) {
+ $this->mUser->setNewtalk( false );
+ }
+ }
}
return $res;
}
diff --git a/includes/api/ApiEchoNotifications.php
b/includes/api/ApiEchoNotifications.php
index 4614ce9..ff3869a 100644
--- a/includes/api/ApiEchoNotifications.php
+++ b/includes/api/ApiEchoNotifications.php
@@ -70,7 +70,7 @@
/**
* Internal method for getting the property 'list' data for individual
section
* @param User $user
- * @param string $section
+ * @param string $section 'alert' or 'message'
* @param int $limit
* @param string $continue
* @param string $format
@@ -81,9 +81,8 @@
$notifUser = MWEchoNotifUser::newFromUser( $user );
$attributeManager = EchoAttributeManager::newFromGlobalVars();
$sectionEvents =
$attributeManager->getUserEnabledEventsbySections( $user, 'web', array(
$section ) );
- // Some section like 'message' only has flow notifications,
which most wikis and
- // users don't have, we should skip the query in such case
- if ( !$sectionEvents || !$notifUser->shouldQuerySectionData(
$section ) ) {
+
+ if ( !$sectionEvents ) {
$result = array(
'list' => array(),
'continue' => null
@@ -92,12 +91,6 @@
$result = $this->getPropList(
$user, $sectionEvents, $limit, $continue,
$format, $unreadFirst
);
- // If events exist for applicable section we should set
the section status
- // in cache to check whether a query should be
triggered in later request.
- // This is mostly for users who don't have 'message'
notifications
- if ( $sectionEvents ) {
- $notifUser->setSectionStatusCache( $section,
count( $result['list'] ) );
- }
}
return $result;
}
@@ -265,7 +258,7 @@
public function getParamDescription() {
return array(
'prop' => 'Details to request.',
- 'sections' => 'The notification sections to query.',
+ 'sections' => 'The notification sections to query (i.e.
some combination of \'alert\' and \'message\').',
'groupbysection' => 'Whether to group the result by
section, each section is fetched separately if set',
'format' => 'If specified, notifications will be
returned formatted this way.',
'index' => 'If specified, a list of notification IDs,
in order, will be returned.',
diff --git a/includes/model/Notification.php b/includes/model/Notification.php
index 334485e..06f86da 100644
--- a/includes/model/Notification.php
+++ b/includes/model/Notification.php
@@ -162,11 +162,6 @@
$notifMapper->insert( $this );
- // Clear applicable section status from cache upon new
notification creation
- $notifUser->clearSectionStatusCache(
- $this->event->getSection()
- );
-
if ( $event->getType() === 'edit-user-talk' ) {
$notifUser->flagCacheWithNewTalkNotification();
}
--
To view, visit https://gerrit.wikimedia.org/r/231736
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I82d7b1d08331693830d6a1749612b55e96b95cf9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits