Commit graph

12 commits

Author SHA1 Message Date
Chad Horohoe
70c2223843 MapCacheLRU: Properly handle bogus cache keys
They can only be strings or integers. Anything else is wrong. We
should be throwing exceptions here so developers find this early
when running tests and manual testing.

Exceptions (instead of warnings) allow us to get a full useful
stacktrace.

Change-Id: I823ce33523283509c14a05f816f261d6b400e243
2016-12-06 12:42:49 -08:00
Kunal Mehta
a41f187511 MapCacheLRU: Support null values in getWithSetCallback()
The rest of this class supports having a key with a null value by using
array_key_exists() instead of isset(). So Use $this->has() in
getWithSetCallback() so a null value is still identified as set.

Change-Id: Ida74a6f7e284e98f9a7d76d97312ebe2ee343f10
2016-09-12 21:45:51 -07:00
Timo Tijhof
f245845056 Revision: Simplify loadText() with nested getWithSetCallback
Check the MapCacheLRU::get() return value properly for misses
this time.

This reverts commit 1f022240c7.

Change-Id: Ic95b79ad8d7d7c788f406d45c0e9bedeeb8d220b
2016-09-07 14:03:01 -07:00
Mattflaschen
1f022240c7 Revert "Revision: Simplify loadText() with nested getWithSetCallback"
This reverts commit aa0f6ead34.

Change-Id: I285ada2e86f014b93c7e7946f10d2dc84375fcff
2016-09-07 20:34:58 +00:00
Timo Tijhof
aa0f6ead34 Revision: Simplify loadText() with nested getWithSetCallback
The logic was a bit hard to follow as there were two layers of
caching and a conditional (expiry being set).

* Move fetch logic for revision text to a private method.
* Call directly when cache is disabled.
* Simplify cache has/get/set by using getWithSetCallback.

Change-Id: Icd74cd8e944266c20dc7c5cb25f56300636dce1e
2016-09-07 18:44:04 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Timo Tijhof
7f01755fdf CacheLRU: Simplify >0 assertion and remove verbose inline comment
* Consistently refer to above zero as '> 0', not ">= 1" or "not <= 0".

* Remove superfluous comment that say what ping() does.

Change-Id: I25d276faa555e02feb99e656eb9cb7071f8205c0
2015-10-20 03:19:17 +01:00
daniel
7081228214 Start using the Assert helper class for checking parameters.
This introduces https://github.com/wmde/Assert as a dependency,
as discussed in the RFC T91071.

This change uses assertions to check some parameters in some places,
to showcase the main intended use case for assertions in MediaWiki.

Bug: T91071
Change-Id: I93ac39b7c146f10532e37b51d973b59b9c424b2f
2015-05-11 17:54:07 +00:00
Alex Monk
156bcbec81 Mostly revert "Verify parameter for MapCacheLRU::has() can be passed to array_key_exists()"
This broke a few things, and the debug line was basically pointless.

Instead, continue to only throw an exception if $text is an object, but only
warn if it's otherwise not a string.

This reverts commit 372ded2fea.

Change-Id: I060da9191cdbd00c4873caba875bfb77c917bcd7
2015-04-07 02:08:11 +00:00
Mark A. Hershberger
372ded2fea Verify parameter for MapCacheLRU::has() can be passed to array_key_exists()
This prevents warnings from PHP from array_key_exists().

Also make sure Title::newFromText throws an exception before it can trigger this.

Bug: T76305
Change-Id: I2b36b7a3b96b37e29fe06f69c13a185b3ec592a7
2015-03-23 15:26:59 -07:00
Aaron Schulz
6417abb728 Added MapCacheLRU::getAllKeys() method
Change-Id: Idc9155bb55d37b083a6c1124721b74d4910ccec5
2014-12-25 14:02:50 -08:00
Aaron Schulz
93d2167ca6 Moved MapCacheLRU to libs/
Change-Id: Icb820787afe7298dd3124f5168d3efff19e53ab6
2014-11-10 22:51:29 +00:00
Renamed from includes/cache/MapCacheLRU.php (Browse further)