Ori.livneh has submitted this change and it was merged.
Change subject: Don't double-serialize values for APC
......................................................................
Don't double-serialize values for APC
The last time we had encountered APC errors related to serialization /
unserialization was 2011. PHP's implementation has had many bugfixes since
then, and HHVM's implementation is a complete rewrite. So let's stop working
around alleged bugs.
To prevent errors resulting from HHVM code receiving serialize()d values when
it isn't expecting them, add a key suffix.
Change-Id: I4b2cf1715538aa3d9163787f43eb31984a380d35
---
M includes/libs/objectcache/APCBagOStuff.php
1 file changed, 13 insertions(+), 17 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/libs/objectcache/APCBagOStuff.php
b/includes/libs/objectcache/APCBagOStuff.php
index eaf1155..cc54fe7 100644
--- a/includes/libs/objectcache/APCBagOStuff.php
+++ b/includes/libs/objectcache/APCBagOStuff.php
@@ -27,43 +27,39 @@
* @ingroup Cache
*/
class APCBagOStuff extends BagOStuff {
+
+ /**
+ * @var string String to append to each APC key. This may be changed
+ * whenever the handling of values is changed, to prevent existing code
+ * from encountering older values which it cannot handle.
+ **/
+ const KEY_SUFFIX = ':1';
+
public function get( $key, &$casToken = null ) {
- $val = apc_fetch( $key );
+ $val = apc_fetch( $key . self::KEY_SUFFIX );
$casToken = $val;
-
- if ( is_string( $val ) ) {
- if ( $this->isInteger( $val ) ) {
- $val = intval( $val );
- } else {
- $val = unserialize( $val );
- }
- }
return $val;
}
public function set( $key, $value, $exptime = 0 ) {
- if ( !$this->isInteger( $value ) ) {
- $value = serialize( $value );
- }
-
- apc_store( $key, $value, $exptime );
+ apc_store( $key . self::KEY_SUFFIX, $value, $exptime );
return true;
}
public function delete( $key ) {
- apc_delete( $key );
+ apc_delete( $key . self::KEY_SUFFIX );
return true;
}
public function incr( $key, $value = 1 ) {
- return apc_inc( $key, $value );
+ return apc_inc( $key . self::KEY_SUFFIX, $value );
}
public function decr( $key, $value = 1 ) {
- return apc_dec( $key, $value );
+ return apc_dec( $key . self::KEY_SUFFIX, $value );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/226458
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4b2cf1715538aa3d9163787f43eb31984a380d35
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.26wmf14
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits