Commit graph

28 commits

Author SHA1 Message Date
Petr Pchelko a10b0b07c8 Use CentralIdLookupFactory and pass UserIdentity
Change-Id: I44144df7cf244eb867c1b261c10cc29b020f8409
2021-07-21 19:23:42 -07:00
James D. Forrester 4dd2a651e1 phpcs: Auto-fix MediaWiki.Usage.StaticClosure.StaticClosure
Change-Id: I6a02902ffaa8a9b497d60b573a0b8e3dbc207ee5
2021-05-04 09:06:42 -07:00
Marko Obrovac 6ae3efc1c3 SeenTime: Do not set the cache key to Unix epoch
Now that seen times are TTL'ed, there is little sense/incentive to set
them in the cache to the default value, since we assume the default
value if they're not in cache (which is being set here). Therefore,
setting them only increases the cache size without any gains.

Bug: T222851
Change-Id: I78a0045e4a53653196114da81c2d60328e78c269
2019-10-18 14:23:28 +02:00
Roan Kattouw ff165c0003 Make EchoSeenTime cache entries expire after 1 year
These entries weren't TTLed at all, and so we had millions of records
for inactive users that were being stored forever. If a user doesn't
view their notifications for a year, it's OK for their notifications
badge to go back to the unseen state until they click it.

(The fallback behavior on a cache miss is to act as if the seentime is
the UNIX epoch, which means that any unread notification they have is
more recent than it, and is considered unseen.)

Bug: T222851
Change-Id: I99230d2351b40751a3f2f5123c5f38693120259e
2019-10-18 12:05:52 +00:00
Roan Kattouw 79ee7582f2 Make EchoSeenTime cache type configurable
Defaults to MainStash, but can be configured to use a different cache
backend by setting $wgEchoSeenTimeCacheType to a string that keys into
$wgObjectCaches.

Bug: T222851
Change-Id: Ifb935cc8be4618f7794ee79a234fc66d5cc5728a
2019-10-18 11:32:03 +00:00
Derick Alangi 7e5e63b1d5 Remove usage of deprecated cache code from Echo
Bug: T221165
Change-Id: Ib7512395b1cc4fd5e13a8d13bd966b1088f34374
2019-04-17 15:22:37 +01:00
jenkins-bot d53af8b8d3 Merge "Use "false" as type hint in PHPDoc tags" 2018-08-16 01:00:05 +00:00
Thiemo Kreuz 8a7c3a78a9 Use "false" as type hint in PHPDoc tags
Most modern IDEs as well as documentation generators understand the
keywords "false" and "true", when a bool can only be one of the two.

Change-Id: I83dd1f0cc0802fa74ee35e7ca7425615230a767f
2018-08-13 15:31:13 +00:00
Thiemo Kreuz c1c3c7b672 Make "@… array" type hints more specific
There are about 200 of such generic "array" type hints in this code base,
the majority in @param tags. I started with what I found most relevant:
@var and @return tags. I might continue working on this later, but
wanted to stop for now to keep this patch moderately small.

Change-Id: Iff0d9590a794ae0f885466ef6bb336b0b42a6cd3
2018-08-13 09:27:37 +02:00
Kunal Mehta aaf061c725 build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.ExtraParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.Commenting.FunctionComment.WrongStyle
* MediaWiki.FunctionComment.Missing.Protected
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I8401abf121a7413fa191d7bc535e0ddd6cf8c3f7
2017-06-22 14:13:28 +00: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
Roan Kattouw 44a210c720 Defer cache write in EchoSeenTime::setTime()
This can be called on GET requests, like when visiting Special:Notifications,
and also from getTime() on a cache miss. Defer the write to the real
cache, but update the in-memory cache immediately.

Bug: T146492
Change-Id: I24db223ded9508942dc0ef1abf55952e98f444d0
2016-09-23 12:11:37 -07:00
Roan Kattouw 8269970305 Remove unused $flags parameter for EchoSeenTime::getTime()
It was always set to 0, and we were using the old (pre-2015)
get() interface so it wouldn't have worked anyway.

Change-Id: Ie92b223a485a5d9d256d2dc69d4ff3807e838878
Bonus: remove documentation for nonexistent parameter for setTime().
2016-09-23 11:53:59 -07:00
Moriel Schottlender 1575e2bb7a Convert 'seenTime' to a global property
This transforms seenTime concept to a global property for all wikis
and sources, and updates the global seen time on opening the popup.

Bug: T134855
Change-Id: I67bcc4b346237317c7a9204dd43cd0e9ee02792f
2016-09-19 14:37:31 -07:00
Catrope bba984c002 Revert "Make seen/unseen badge more consistent across wikis"
Has bugs, and will likely cause deployment problems.
This'll need to be reverted in wmf.19 at least
until we fix it up.

This reverts commit 00e0b9f45d.

Change-Id: Ia9d220ebcb607f96dee6bc856755305ed8501fcc
2016-09-13 14:21:32 -07:00
Matthew Flaschen 98c6cd9eab Fix seen time for new users
Until the user opens the popup the first time, everything should be
unseen, rather than nothing unseen.

Also, make the default 'everything unseen' if we forget their seen
time.

Change-Id: I99ff8d46d4fa2fab0db374ddff63727b18a68363
2016-09-09 17:46:34 -04:00
Moriel Schottlender 00e0b9f45d Make seen/unseen badge more consistent across wikis
- Add a 'hasUnseen' data to the xwiki bundle so the badge can
  consider its value when changing its color even without the
  bundle being opened.
- Check and store seenTimes from all sources that the xwiki
  has in a new JS object that the SeenTimeModel can store

Bug: T134855
Change-Id: Ifdcee88b4378cdc7acb4ae5c0cbc60b76339757e
2016-09-08 12:40:15 -07:00
Chad Horohoe da4f8f5db9 Use static cache for times so it works across instances of SeenTime
Follows-up If6319a02. Making the cache static enables us to reuse
the in-process cache across multiple instances of the class.

Bug: T144534
Change-Id: I1a594830f13d56ab4e0e636a3cdb5e96379e990a
2016-09-08 12:24:46 -07:00
Kunal Mehta b3cdd56952 SeenTime: Wrap cache with CachedBagOStuff
That adds an in-process cache so we don't have duplicate key lookups on
every request.

Bug: T144534
Change-Id: If6319a026c457a32bfde0e212c6193aa728cb208
2016-09-06 13:06:26 -07:00
Moriel Schottlender 879fe27bc6 When fetching combined seenTime, get 'min' value rather than max
This will make the mobile view show unseen state if any of the
badges have unseen state rather than not show it if one of the
badges was more recently seen than the other in desktop.

Bug: T141404
Change-Id: I27109ee6a24831d58767f9bd13ed58e54094aee1
2016-08-01 19:14:51 +00:00
Matthew Flaschen 954e076fd1 SeenTime: For 'all', use MW, then convert after taking max.
Lesser-used formats like TS_ORACLE are not string-comparable.

Change-Id: I7a9fd3ac0c8b1e924f6f0e8970f7a005858df9d7
2016-07-28 20:11:30 -04:00
Moriel Schottlender b623bdc6d3 Forward format to seenTime when getting 'all' types
Change-Id: Id79c4403ea879bb08b0ce94d24f7bdbb8ea83560
2016-07-28 15:09:16 -07:00
jenkins-bot bf502f89a0 Merge "Allow requesting TS_ISO_8601 for ApiEchoMarkSeen, and deprecate TS_MW" 2016-07-21 02:04:06 +00:00
Matthew Flaschen 756948d489 Allow requesting TS_ISO_8601 for ApiEchoMarkSeen, and deprecate TS_MW
(Previously TS_MW was the only possibility).

Per https://www.mediawiki.org/wiki/API:Data_formats#Timestamps

Bug: T139993
Change-Id: Ief9a720a5053ee153b84edb64524aa4743cc76f1
2016-07-20 18:22:28 -04:00
Matthew Flaschen c05133283a Add seen time to output of API, in ISO 8601 format
Like count, it is available both grouped by section and ungrouped
(top-level).

Unlike count, the top-level still has both sections (but with the
string 'seenTime' at the root), and if groupbysection is used,
it will not also have top-level (since it would be redundant).

Example output at T139993

It will be false or omitted if there is no seen time, depending
on JSON format version (2+ is false).

Bug: T139993
Change-Id: I9f4f9df69203204b56002afa1be6ed2336c33898
2016-07-20 09:25:03 -07:00
Siebrand Mazeland 33126b69aa Update formatting
In preparation of Code Sniffer based updates.

Change-Id: Id5d43332b44a37665d57dc24ef8c432bc65b2f6a
2015-10-03 23:28:54 -04:00
Moriel Schottlender e650df6644 Separate 'seen time' for alerts and messages
Bug: T111285
Change-Id: I277f94ae705d3323ac8612111d7fd704b36793cb
2015-09-03 13:14:15 -07:00
Kunal Mehta 35c4a37918 Use db-replicated objectcache for storing last seen time
So we're not abusing user preferences for the last seen time.
EchoSeenTime is a small wrapper around ObjectCache that handles the
fallback to user preferences during the transition.

All JavaScript code now needs to use mw.config.get('wgEchoSeenTime').

Bug: T95839
Change-Id: Ia45ba5e30eb4564250539d04d5886d2598ebd49a
2015-09-02 22:42:35 +00:00