Make adaptiveTTL() less strict about $mtime type
Callers using wfTimestamp( TS_UNIX, ... ) where getting $minTTL due to the output being a string number. Change-Id: I6b67a941940f40ef9a543f11d0dbccacafaaa53b
This commit is contained in:
parent
dc178bf8f6
commit
3348200473
2 changed files with 7 additions and 2 deletions
|
|
@ -1086,8 +1086,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
|
|||
* @since 1.28
|
||||
*/
|
||||
public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = .2 ) {
|
||||
if ( is_float( $mtime ) ) {
|
||||
$mtime = (int)$mtime; // ignore fractional seconds
|
||||
if ( is_float( $mtime ) || ctype_digit( $mtime ) ) {
|
||||
$mtime = (int)$mtime; // handle fractional seconds and string integers
|
||||
}
|
||||
|
||||
if ( !is_int( $mtime ) || $mtime <= 0 ) {
|
||||
|
|
|
|||
|
|
@ -734,6 +734,11 @@ class WANObjectCacheTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertGreaterThanOrEqual( $adaptiveTTL - $margin, $ttl );
|
||||
$this->assertLessThanOrEqual( $adaptiveTTL + $margin, $ttl );
|
||||
|
||||
$ttl = $this->cache->adaptiveTTL( (string)$mtime, $maxTTL, $minTTL, $factor );
|
||||
|
||||
$this->assertGreaterThanOrEqual( $adaptiveTTL - $margin, $ttl );
|
||||
$this->assertLessThanOrEqual( $adaptiveTTL + $margin, $ttl );
|
||||
}
|
||||
|
||||
public static function provideAdaptiveTTL() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue