jenkins-bot has submitted this change and it was merged.
Change subject: objectcache: Remove getWithSetCallback() signature
backwards-compatability
......................................................................
objectcache: Remove getWithSetCallback() signature backwards-compatability
All callers have been migrated
Change-Id: I7b6b87594dd724434ba24d8206fe07d66c1d5d25
---
M includes/libs/objectcache/WANObjectCache.php
M tests/phpunit/includes/objectcache/WANObjectCacheTest.php
2 files changed, 16 insertions(+), 31 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/libs/objectcache/WANObjectCache.php
b/includes/libs/objectcache/WANObjectCache.php
index 3b9c832..e68740e 100644
--- a/includes/libs/objectcache/WANObjectCache.php
+++ b/includes/libs/objectcache/WANObjectCache.php
@@ -656,26 +656,9 @@
* since the callback should use slave DBs and they may be lagged
or have snapshot
* isolation anyway, this should not typically matter.
* Default: WANObjectCache::TTL_UNCACHEABLE.
- * @param array $oldOpts Unused (mentioned only to avoid PHPDoc
warnings)
* @return mixed Value to use for the key
*/
- final public function getWithSetCallback(
- $key, $ttl, $callback, array $opts = array(), $oldOpts = array()
- ) {
- // Back-compat with 1.26: Swap $ttl and $callback
- if ( is_int( $callback ) ) {
- $temp = $ttl;
- $ttl = $callback;
- $callback = $temp;
- }
- // Back-compat with 1.26: $checkKeys as separate parameter
- if ( $oldOpts || ( is_array( $opts ) && isset( $opts[0] ) ) ) {
- $checkKeys = $opts;
- $opts = $oldOpts;
- } else {
- $checkKeys = isset( $opts['checkKeys'] ) ?
$opts['checkKeys'] : array();
- }
-
+ final public function getWithSetCallback( $key, $ttl, $callback, array
$opts = array() ) {
$pcTTL = isset( $opts['pcTTL'] ) ? $opts['pcTTL'] :
self::TTL_UNCACHEABLE;
// Try the process cache if enabled
@@ -683,7 +666,7 @@
if ( $value === false ) {
// Fetch the value over the network
- $value = $this->doGetWithSetCallback( $key, $ttl,
$callback, $checkKeys, $opts );
+ $value = $this->doGetWithSetCallback( $key, $ttl,
$callback, $opts );
// Update the process cache if enabled
if ( $pcTTL >= 0 && $value !== false ) {
$this->procCache->set( $key, $value, $pcTTL );
@@ -701,15 +684,13 @@
* @param string $key
* @param integer $ttl
* @param callback $callback
- * @param array $checkKeys
* @param array $opts
* @return mixed
*/
- protected function doGetWithSetCallback(
- $key, $ttl, $callback, array $checkKeys, array $opts
- ) {
+ protected function doGetWithSetCallback( $key, $ttl, $callback, array
$opts ) {
$lowTTL = isset( $opts['lowTTL'] ) ? $opts['lowTTL'] : min(
self::LOW_TTL, $ttl );
$lockTSE = isset( $opts['lockTSE'] ) ? $opts['lockTSE'] :
self::TSE_NONE;
+ $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] :
array();
// Get the current key value
$curTTL = null;
diff --git a/tests/phpunit/includes/objectcache/WANObjectCacheTest.php
b/tests/phpunit/includes/objectcache/WANObjectCacheTest.php
index 8981f2f..c3702c5 100644
--- a/tests/phpunit/includes/objectcache/WANObjectCacheTest.php
+++ b/tests/phpunit/includes/objectcache/WANObjectCacheTest.php
@@ -3,6 +3,8 @@
class WANObjectCacheTest extends MediaWikiTestCase {
/** @var WANObjectCache */
private $cache;
+ /**@var BagOStuff */
+ private $internalCache;
protected function setUp() {
parent::setUp();
@@ -104,7 +106,7 @@
};
$wasSet = 0;
- $v = $cache->getWithSetCallback( $key, $func, 30, array(),
array( 'lockTSE' => 5 ) );
+ $v = $cache->getWithSetCallback( $key, 30, $func, array(
'lockTSE' => 5 ) );
$this->assertEquals( $value, $v, "Value returned" );
$this->assertEquals( 1, $wasSet, "Value regenerated" );
@@ -114,7 +116,7 @@
$this->assertGreaterThanOrEqual( 19, $curTTL, 'Current TTL
between 19-20 (overriden)' );
$wasSet = 0;
- $v = $cache->getWithSetCallback( $key, $func, 30, array(),
array(
+ $v = $cache->getWithSetCallback( $key, 30, $func, array(
'lowTTL' => 0,
'lockTSE' => 5,
) );
@@ -124,7 +126,8 @@
$priorTime = microtime( true );
usleep( 1 );
$wasSet = 0;
- $v = $cache->getWithSetCallback( $key, $func, 30, array(
$cKey1, $cKey2 ) );
+ $v = $cache->getWithSetCallback( $key, 30, $func,
+ array( 'checkKeys' => array( $cKey1, $cKey2 ) ) );
$this->assertEquals( $value, $v, "Value returned" );
$this->assertEquals( 1, $wasSet, "Value regenerated due to
check keys" );
$t1 = $cache->getCheckKeyTime( $cKey1 );
@@ -134,7 +137,8 @@
$priorTime = microtime( true );
$wasSet = 0;
- $v = $cache->getWithSetCallback( $key, $func, 30, array(
$cKey1, $cKey2 ) );
+ $v = $cache->getWithSetCallback( $key, 30, $func,
+ array( 'checkKeys' => array( $cKey1, $cKey2 ) ) );
$this->assertEquals( $value, $v, "Value returned" );
$this->assertEquals( 1, $wasSet, "Value regenerated due to
still-recent check keys" );
$t1 = $cache->getCheckKeyTime( $cKey1 );
@@ -149,10 +153,10 @@
$wasSet = 0;
$key = wfRandomString();
- $v = $cache->getWithSetCallback( $key, $func, 30, array(),
array( 'pcTTL' => 5 ) );
+ $v = $cache->getWithSetCallback( $key, 30, $func, array(
'pcTTL' => 5 ) );
$this->assertEquals( $value, $v, "Value returned" );
$cache->delete( $key );
- $v = $cache->getWithSetCallback( $key, $func, 30, array(),
array( 'pcTTL' => 5 ) );
+ $v = $cache->getWithSetCallback( $key, 30, $func, array(
'pcTTL' => 5 ) );
$this->assertEquals( $value, $v, "Value still returned after
deleted" );
$this->assertEquals( 1, $wasSet, "Value process cached while
deleted" );
}
@@ -172,13 +176,13 @@
};
$cache->delete( $key );
- $ret = $cache->getWithSetCallback( $key, 30, $func, array(),
array( 'lockTSE' => 5 ) );
+ $ret = $cache->getWithSetCallback( $key, 30, $func, array(
'lockTSE' => 5 ) );
$this->assertEquals( $value, $ret );
$this->assertEquals( 1, $calls, 'Value was populated' );
// Acquire a lock to verify that getWithSetCallback uses
lockTSE properly
$this->internalCache->lock( $key, 0 );
- $ret = $cache->getWithSetCallback( $key, 30, $func, array(),
array( 'lockTSE' => 5 ) );
+ $ret = $cache->getWithSetCallback( $key, 30, $func, array(
'lockTSE' => 5 ) );
$this->assertEquals( $value, $ret );
$this->assertEquals( 1, $calls, 'Callback was not used' );
}
--
To view, visit https://gerrit.wikimedia.org/r/247066
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7b6b87594dd724434ba24d8206fe07d66c1d5d25
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits