From 9f0d40e08f1b8b562d89457a6c1a0eb5dbfa7828 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 7 Oct 2014 16:24:45 +1100 Subject: [PATCH] HashBagOStuff: use the value itself as the CAS token Avoid an unnecessary serialize() call on get() requests, which makes it faster and also happens to work around a nasty crash bug which is causing lots of segfaults right now. CAS semantics should be the same, if the caller handles a CAS token in an opaque way and does not assume it is a string. I could only find one caller of cas() in core and WMF deployed extensions, and that is BagOStuff::mergeViaCas(), which does correctly handle CAS tokens of any type. Bug: 71724 Change-Id: I0b0b5f0157c005ec7f76210dfb8576c056314733 --- includes/objectcache/HashBagOStuff.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/objectcache/HashBagOStuff.php b/includes/objectcache/HashBagOStuff.php index 6e50a8c39f..06a08655e9 100644 --- a/includes/objectcache/HashBagOStuff.php +++ b/includes/objectcache/HashBagOStuff.php @@ -65,7 +65,7 @@ class HashBagOStuff extends BagOStuff { return false; } - $casToken = serialize( $this->bag[$key][0] ); + $casToken = $this->bag[$key][0]; return $this->bag[$key][0]; } @@ -89,7 +89,7 @@ class HashBagOStuff extends BagOStuff { * @return bool */ function cas( $casToken, $key, $value, $exptime = 0 ) { - if ( serialize( $this->get( $key ) ) === $casToken ) { + if ( $this->get( $key ) === $casToken ) { return $this->set( $key, $value, $exptime ); } -- 2.20.1