From: Tim Starling Date: Tue, 7 Oct 2014 05:24:45 +0000 (+1100) Subject: HashBagOStuff: use the value itself as the CAS token X-Git-Tag: 1.31.0-rc.0~13671 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=9f0d40e08f1b8b562d89457a6c1a0eb5dbfa7828;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ); }