Page MenuHomePhabricator

The feed on Special:RecentChanges is cached in random language
Closed, ResolvedPublic

Description

Include language in the cache key

The feed for recent changes is cached (for at least $wgFeedCacheTimeout seconds). The cache key considers limit, hideminor (and target), and the code prevents tries to prevent other options from having effect (stating “Feed is cached on limit,hideminor; other params would randomly not work”).

However, the user language, and the uselang query parameter still have effect. That means that the feed gets cached in the preferred language of the user who triggered its rendering, and that language is served to all users during the cache timeout period. (Check e.g. http://ab.wiktionary.org/w/index.php?title=Special:RecentChanges&feed=rss&uselang=ru and immediately afterwards just http://ab.wiktionary.org/w/index.php?title=Special:RecentChanges&feed=rss)

There are, in principle, two ways of solving this bug: 1. Fix the feed so that is always generated in the content language, no matter what the user wants. 2. Change the caching key to include the language.

The first option would not only be user-unfriendly (see also bug #17868), it would also be quite difficult to achieve. Not only does the preferred language affect the feed format, it also affects contents of displayed log events, etc.

Since the second option is also easy to implement, so I am providing a simple patch.


Version: unspecified
Severity: minor
URL: http://ab.wiktionary.org/w/index.php?title=Special:RecentChanges&feed=rss&uselang=ru

Attached:

Details

Reference
bz19391

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:41 PM
bzimport set Reference to bz19391.
bzimport added a subscriber: Unknown Object (MLST).
Mormegil created this task.Jun 25 2009, 2:15 PM

The recent changes feed is from 100-250kb (arguably another issue) and is cached forever. Are you suggesting that we should add one for every language that may be used by visitors? This could eat up cache pretty quickly.

When I looked at the source, I was surprised to see that, indeed, the cached RC feed data does not expire. I believe this is just a plain bug: the feed data should expire after 24 h, just like its timestamp does (adding a patch in a while).

So, assuming this gets fixed, the feed is cached only for languages somebody requested, and only for at most 24 h.

If that does not look acceptable to you, we are left with only the other option I mentioned: force content language always. But, that means saying “no” to the users requesting otherwise (see that bug #17868), and is not completely trivial – you will probably need to set wgLang to wgContLang during feed rendering (or refactor at least FeedUtils::formatDiff (and possibly other places) to explicitly pass the language to use; (mmm… that $wgUser->getSkin() seems interesting, too…).

Oh, in fact, we do have yet another option: keep the functionality as it is, only if wgLang!=wgContLang, do not cache the feed. But that would be a possibility to a DOS attack or something like that. (Or, we could use much shorter cache timeouts for those languages.)

Created attachment 6278
Use expiration not only for the timestamp, but also for the feed data

Currently, the feed timestamp stored in the cache expires in 24 hours, but the feed data does not expire at all, which is nonsense, since the data is used only if the timestamp is found in the cache.

Attached:

In bug 19812#c1 you see me "go pick some odd limit" to workaround. Yuck,

Bryan.TongMinh wrote:

Applied in r58978.