$ret = true;
$args = array_slice( func_get_args(), 3 );
+ if ( $count > 1 && $asyncWrites ) {
+ // Deep-clone $args to prevent misbehavior when something writes an
+ // object to the BagOStuff then modifies it afterwards, e.g. T168040.
+ $args = unserialize( serialize( $args ) );
+ }
+
foreach ( $this->caches as $i => $cache ) {
if ( $i >= $count ) {
break; // ignore the lower tiers
*/
public function testSetDelayed() {
$key = wfRandomString();
- $value = wfRandomString();
+ $value = (object)[ 'v' => wfRandomString() ];
+ $expectValue = clone $value;
// XXX: DeferredUpdates bound to transactions in CLI mode
$dbw = wfGetDB( DB_MASTER );
$dbw->begin();
$this->cache->set( $key, $value );
+ // Test that later changes to $value don't affect the saved value (e.g. T168040)
+ $value->v = 'bogus';
+
// Set in tier 1
- $this->assertEquals( $value, $this->cache1->get( $key ), 'Written to tier 1' );
+ $this->assertEquals( $expectValue, $this->cache1->get( $key ), 'Written to tier 1' );
// Not yet set in tier 2
$this->assertEquals( false, $this->cache2->get( $key ), 'Not written to tier 2' );
$dbw->commit();
// Set in tier 2
- $this->assertEquals( $value, $this->cache2->get( $key ), 'Written to tier 2' );
+ $this->assertEquals( $expectValue, $this->cache2->get( $key ), 'Written to tier 2' );
}
/**