Commit graph

60 commits

Author SHA1 Message Date
Umherirrender 546e3bdd55 Improve some parameter docs
Change DB_SLAVE in comments

Change-Id: Idd5787928b87f5af63864dc626cb603f281515d7
2017-10-18 18:44:52 +02:00
jenkins-bot 746b965fb2 Merge "Fix PHPDoc Documentation" 2017-10-02 22:53:47 +00:00
David Barratt d76ff6e32f Fix PHPDoc Documentation
Documentation is throwing linter errors and needs to be fixed.

Bug: T173475
Change-Id: Ic120b6a7a1f29ea90a939c4348202c09d47c38f5
2017-10-02 18:40:46 -04:00
libraryupgrader 7a23ddf4b0 build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: I7b19fab3b1100c4973600ec95ee24160e141c5ac
2017-09-24 09:49:43 +00:00
Brad Jorsch 1f9eedf40f Remove reference to deprecated IDatabase->nextSequenceValue()
The method was deprecated and made unnecessary in Ib308190c.

Change-Id: I47aca6a7c77821119f52e639d0e74a1e6302532a
2017-09-06 13:05:14 -04:00
Umherirrender 5b4730c9bc Improve some parameter docs
Change-Id: Ie71fb080926781f2905e6264be060203c56185ea
2017-08-09 17:21:10 +02:00
Umherirrender 79b6f470af build: Updating mediawiki/mediawiki-codesniffer to 0.10.1
Change-Id: I2326cf81e907f2a02615f96f922b66fd2806defd
2017-07-26 21:34:44 +02:00
Brad Jorsch d7a77b0aba Fix usage of $db->nextSequenceValue()
The return value from the method is only suitable for passing to
$db->insert(). To get the inserted ID, you need to call $db->insertId()
even if $db->nextSequenceValue() returned non-null.

Bug: T164900
Change-Id: I466fd372804927b3ad72125c7a69d253bd7a24f8
2017-05-10 17:46:07 -04:00
Roan Kattouw 2e4e14498a EventMapper: Don't retry failed lookup queries on the master on GET
Only retry lookups if there are multiple DB servers and
changes were made in this request. This same logic is used
in a couple of places in MW core, like WikiPage::loadPageData()
and Revision::newFromConds().

Bug: T164505
Change-Id: If1af363f9687019864b5eaef72ffe0bc824a2223
2017-05-04 17:49:33 -07:00
James D. Forrester 8c810dff48 build: Update mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I25cb61b3b92798f1259d1575a336e2b056d5764f
2016-12-05 15:54:30 -08:00
Stephane Bisson b3c07eedeb Remove etp_user
Target page entries used to exist for each user
that was notified for an event. They were
removed as the notifications were marked as read.

Now they remain so that the association between
pages and events can be used for moderation
regardless of the notifications read status.

This patch removes everything about
echo_target_page.etp_user from sql and php code.

Bug: T143959
Change-Id: Ib57510e6b0e9202a7e035f8ea59955dca8a0b24a
2016-09-09 09:32:28 -04:00
jenkins-bot c82e390591 Merge "Remove unused method EchoEventMapper::fetchByUserBundleHash" 2016-08-26 00:17:59 +00:00
Stephane Bisson 9dd4e4ee30 Don't select echo_event.*
Removed fetchByTypesAndPage since it is now unused

Fixed fetchByPage to select simple * instead of
echo_event.*

Bug: T105890
Change-Id: I486f27501a649d5368305965d2cd012afe0915b2
2016-08-24 12:56:49 -04:00
Roan Kattouw ce3d6b2f49 Remove unused method EchoEventMapper::fetchByUserBundleHash
Bug: T143763
Change-Id: Iad63e8866eeccf316b3efe3a44888256c0c407d8
2016-08-23 19:22:01 -07:00
Stephane Bisson 6e2236db81 Moderate notifications
* When a page is deleted, moderate associated
  notifications. When it is undeleted, unmoderate.

* When a notification cannot be rendered
  (canRender() returns false), moderate it.

The biggest advantage of moderation over mark-read-and-ignore
is that those notifications are filtered out at the database
level from this point on. They are not re-processed every single
time and do not affect the number of notifications returned by
the API.

Bug: T140327
Bug: T140836
Bug: T141463
Change-Id: Idefe78408fd584c13aaa9174cee3055539d92848
2016-08-19 22:20:04 +00:00
Aaron Schulz 9d436067a7 Convert deferred update to using AtomicSectionUpdate
Change-Id: Ic30a940d243986e71cfc8e66a70c0c2e77438506
2016-07-21 23:43:21 -07:00
Stephane Bisson 24caf50ff6 Dynamic bundles
To allow individual notifications to be
marked as read/unread or moderated,
bundles are created by grouping associated
notifications when they are fetched for display
instead of when they are created.

From a product perspective, this change doesn't
introduce moderation or expandable bundles but
it counts each individual notifications.
For instance, the bundled notification
"3 new topics on PageA" now counts as 3
notifications.

Bug: T93673
Bug: T120153
Change-Id: Iacd098573efd92bb1e3fcd7da4cd40cea9522f15
2016-06-27 09:49:13 -04:00
Roan Kattouw 7d97881344 Add support for querying notifications not associated with any page
Uses the magic value '[]' to mean 'no title'. This is a bit ugly,
but I think introducing an additional &notwithouttitle=1 parameter
is uglier and results in more code.

Change-Id: I83278182aeaf3905eb0f3e24c4c6c247720b1e76
2016-06-24 00:37:21 +02:00
jenkins-bot 7a6d0f6aa3 Merge "ApiEchoNotificatons: Add nottitles parameter" 2016-06-16 12:09:46 +00:00
Stephane Bisson b06b2294c9 Allow the primary link to set all bundled notifications as read
Bug: T136368
Change-Id: If07369cb168d1a085f297293e713d65e49997264
2016-06-14 08:49:23 -04:00
Roan Kattouw 016e6dabda ApiEchoNotificatons: Add nottitles parameter
To only show notifications related to a certain title
(or set of titles).

Bug: T137139
Change-Id: I5c82e02bc8e8553c5b761a771b975f03d943d408
2016-06-13 20:19:32 +01:00
Stephane Bisson 6564919c28 Don't fetch duplication notifications
Avoid joining on echo_taget_page to prevent fetching
duplicate notifications.

Change-Id: Ibcda67ce2fa387d8be0ffcb405bd0692965dddcb
2016-05-27 21:47:36 -07:00
Kunal Mehta 64127cd815 Avoid exceptions when event_extra can't be unserialized
Check for proper unserialization in EchoEvent::loadFromRow(), and return
false if not possible. Callers were updated to check for a false return.

Bug: T73489
Change-Id: I33867aa9bbbc5f0ecfe0d2a9e1b03eb1a937ae83
2016-05-13 16:39:17 -07:00
Kunal Mehta b6f742bc46 Add plain text email formatter
Formatters based on presentation models for
individual event emails and digest (daily, weekly)
plain text emails.

Bug: T121067
Change-Id: I4eceaf521315adab7429a8a73ffca70ebcddab86
2016-05-04 13:35:37 -04:00
Roan Kattouw 7942a2de79 Replace mark-as-read-on-click with ?markasread= URL parameter
Notifications were being marked as read in response to a click event
in JavaScript, but that causes a jarring effect in the UI, and it's
not reliable (the browser could abort the AJAX request).

Instead, add ?markasread=XYZ to the end of every primary link URL,
where XYZ is the event ID.

Bug: T133975
Depends-On: Icb99d5479836fea25a47451b5a758dd71f642f71
Change-Id: I8047d121584b43e6172463a50ad0e0de5f7fa73c
2016-05-03 00:20:03 -07:00
Kunal Mehta 26a8bc2450 Defer onPersonalUrls() DB writes to post-send (try #2)
This reverts commit e372f3ce6f.

The previous attempt was broken because
EchoTargetPageMapper::fetchByUserPageId() returns a list of
EchoTargetPage objects, not a single one.

Bug: T117531
Change-Id: Id02a025e3736a7b92d9d6fb8adf29ef674f8e2fa
2016-03-09 11:07:50 -08:00
Catrope e372f3ce6f Revert "Defer onPersonalUrls() DB writes to post-send"
Causes fatals in production for some reason.

This reverts commit 93387806c2.

Bug: T129299
Change-Id: Ie90aa493e2940fae9d6f380b95f87a4cc7e04622
2016-03-09 00:00:11 +00:00
Aaron Schulz 93387806c2 Defer onPersonalUrls() DB writes to post-send
We calculate how many messages and alerts are being marked as read, and
subtract them from the count since the database and caches won't be
updated until the end of the request.

For performance, we also get the event_type while doing the
EchoTargetPage lookup query to avoid having to query it individually
later on.

Bug: T117531
Change-Id: I0d9302adf1b4b07a4ff26a04b00d4498aa3fe7ee
2016-03-08 01:41:52 +00:00
Matthias Mullie f8a483d1f8 Add filter to ApiEchoNotifications
It lets you query for read/unread/all notifications.

Bug: T119890
Change-Id: I5d09b5ff9474c77577734e9ceb0bcbcad6c99c0c
2015-12-14 17:29:52 +01:00
Matthias Mullie 55cc28dd81 Also support continuation requests for $unreadFirst
Right now, it'll only respond a certain, fixed, amount,
not allowing you to paginate the list.

Note: haven't properly tested all possible cases yet!

Change-Id: I84761b13a1b9203cb8e3fcc80941d739cd28659f
2015-12-10 17:33:32 +01:00
Matthias Mullie 2a1abc0281 Share code between EchoNotificationMapper::fetchByUser & fetchUnreadByUser
The only difference at this point is that fetchByUser initializes
the EchoNotification object with $targetPages. It doesn't really
matter that it doesn't have the target pages, since fetchUnreadByUser
is currently only used in the flyout, where those target pages aren't
used. But regardless of what method was used to fetch the data, I
think the data should be the same.

And now, there's less code duplication...

Change-Id: I04c7b98794af5427a2217dd337108e7eea1e65c5
2015-12-10 17:19:46 +01:00
Kunal Mehta a00628b42a EventMapper::fetchByUserBundleHash(): Always return an array
It's basically impossible for DatabaseBase::select() to return false now
that ignoreErrors() is protected. So always return an array so callers
don't have to worry about false.

And remove a test that checked the result if DatabaseBase::select() did
return false.

Change-Id: I9ca8511585403d8c0ec262898ad4e61c2b038d51
2015-11-19 10:12:43 -08:00
Kunal Mehta fb56d61d68 Fix some phpdoc, add missing @throws
Change-Id: Iba072d64443ed9117233f591f1aea3cc6a4adc44
2015-11-12 14:10:52 -08:00
James D. Forrester cd8c77df29 build: Enable phpcs rule 'MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment' and make pass
Change-Id: Ied1a479e6f5aa82d03e449ec10d655a921cd37e4
2015-10-29 13:06:14 +01:00
Siebrand Mazeland 33126b69aa Update formatting
In preparation of Code Sniffer based updates.

Change-Id: Id5d43332b44a37665d57dc24ef8c432bc65b2f6a
2015-10-03 23:28:54 -04:00
Matthew Flaschen f3342a6c39 Put back notification_timestamp for web.
Although it wasn't here even before
c94c3f3dad , loadFromRow will make
use if it if it's present.  Otherwise, it's the current timestamp
(which seems odd; if we really don't need the timestamp in a
particular scenario, null would be more straightforward).

This is also public (getTimestamp()).

Change-Id: I9d88d86dde5b7f9b5965c81225a2aab4354c2baa
2015-08-26 16:06:34 -04:00
Alex Monk 92dc3a0d3c Fix fatal DB exception
Follow-up I6c956738, which started trying to pull notification_timestamp out
of nowhere. Although EchoEvent::newFromRow may try to use this if it's set, it
wasn't previously getting selected and this is now causing exceptions.

Bug: T105890
Change-Id: I2dd9e268428d651813d8c43d85d54fc97634cd41
2015-08-26 13:31:51 +00:00
Federico Leva c94c3f3dad Select specific rows in EchoEventMapper::fetchByUserBundleHash()
As needed by EchoEvent::loadFromRow().
Alternatively, just '*' as in MWEchoEmailBatch::getEvents().

Bug: T105890
Change-Id: I6c956738125658607d5e548efad4031c3298020f
2015-08-22 10:11:39 +02:00
Matthias Mullie 6bcece22cc Don't repopulate cache with potentially lagging DB data
getNotificationCount & getLastUnreadNotificationTime have an
argument $cached that allows cache to be bypassed & read from
DB. That result is then stored to cache.

In practice, it seems to be used only for cache invalidation.
getLastUnreadNotificationTime didn't allow to specify the DB
to be read from, and EchoNotificationMapper::fetchUnreadByUser
only read from slave.
So when we wanted to invalidate the cache, we would end up
immediately repopulating it with data from a (potentially and
likely) lagging slave.

I've made it accept the DB type, similar to getNotificationCount.

Bug: T98421
Change-Id: Ie4b09eeb04b9827b454cb2d92ee8c674bdd59a19
2015-05-07 14:01:56 +02:00
Erik Bernhardson 70639162f3 Allow multiple target pages per event
Bug: T85064
Change-Id: I338f3d73efb98a3bb66ef64fdeeb66e752a453c2
2015-03-31 07:56:52 +00:00
Erik Bernhardson e9f1e67487 Hygiene: Remove unused method on EchoTargetPageMapper
Change-Id: Ic2517bf095421ced125c653716fbf44c7934a1e9
2015-03-16 08:48:22 -07:00
jenkins-bot ffe55d81b4 Merge "I-2. Change the default number of Flow Messages in the flyout" 2014-10-27 14:50:19 +00:00
Erik Bernhardson b552201829 I-2. Change the default number of Flow Messages in the flyout
Previously this was loading 25 unread notifications.  If less than 25 were
found it would add in 3 read notifications so it wasn't empty.

This patch changes things around to always return 25 notifications if the
user has at least that many.  Instead of backfilling a static count of 3
we backfill 25 - $count with previously read notifications.

Change-Id: I723316486216d7b9dacfcc9765c1a8212e973518
2014-10-15 10:08:00 -07:00
jenkins-bot ce51ecb8f0 Merge "Add reverse chronological ordering to unread notifications" 2014-10-07 18:01:48 +00:00
Erik Bernhardson 0cfe5ca269 Don't fatal if a notification fails to initialize
Log info to Echo debug log group instead.

Bug: 71489
Change-Id: I4a7c669ef55936e3c683d268041d828b54a5a9b2
2014-10-01 01:11:30 +00:00
bsitu 371abf6430 Add reverse chronological ordering to unread notifications
Has a performance impact, so this depends on deploying the job
that deletes older notifications.

Bug: 69919
Change-Id: Ia485c853d1b04c3c85e25e6a12f5060a046e9b11
2014-09-29 23:14:42 +00:00
bsitu 55ef794d74 Add job to keep user notifications in reasonable volume
Change-Id: I4d4fa4c987a1732e5e29536a7669e28c34d4ab18
2014-09-29 23:10:18 +00:00
bsitu 8e2de3f02b Add support to retrieve unread + read notifcations for section
Change-Id: Ife3750400315f545f5f3e54ac9847f56c2efe9be
2014-08-19 16:54:48 -07:00
jenkins-bot 124cbbd036 Merge "Auto mark notification as read if it doesn't have target page" 2014-08-15 18:35:27 +00:00
bsitu 1cc0f83829 Move 'notification count refresh' logic out of mapper
Change-Id: I4c10b66e537dea5f9c5bc7ccba8f558cafd103d7
2014-08-15 16:02:23 +02:00