On Mon, Apr 3, 2017 at 12:56 AM, Nischay Nahata <nischayn22(a)gmail.com>
wrote:
I have been trying to add certain rate limiting actions for my extension's
API and noticed that it doesn't work with $wgMainCacheType set to
CACHE_NONE
This is because User::pingLimiter()
uses ObjectCache::getLocalClusterInstance() to store the current rate
limit
counts.
Is this the expected behavior? Looks pretty deceitful to me
as $wgMainCacheType is assumed to define the cache type but is actually
disabling a core functionality like rate limiting and maybe few others?
I'm pretty sure this one's my fault -- at the time it was added we didn't
expect the rate limit feature to be used in a minimal configuration without
an object cache configured, and it ended up being kind of kept that way
through the years.
I would recommend probably changing this:
$cache = ObjectCache::getLocalClusterInstance();
to:
$cache = ObjectCache::getInstance( CACHE_ANYTHING );
That should set the rate limiter to use the database-backed cache when
$wgMainCacheType is set to CACHE_NONE, and will use the main cache when
it's not set off.
-- brion