From 6aaf0f9359ab1bd2bfd615974cf6f65a698551aa Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 8 Jun 2016 10:25:25 -0700 Subject: [PATCH] Avoid getWithSetCallback() warnings on unversioned key migration If an unversioned key is present, this generated a warning previously. Bug: T137244 Change-Id: I92df9b9fe0436348b5b27e684d239238d57c9b5f --- includes/libs/objectcache/WANObjectCache.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index f12cb4ccbc..45713cc814 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -800,7 +800,15 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { $key, $ttl, function ( $oldValue, &$ttl, &$setOpts ) use ( $callback, $version ) { - $oldData = $oldValue ? $oldValue[self::VFLD_DATA] : false; + if ( is_array( $oldValue ) + && array_key_exists( self::VFLD_DATA, $oldValue ) + ) { + $oldData = $oldValue[self::VFLD_DATA]; + } else { + // VFLD_DATA is not set if an old, unversioned, key is present + $oldData = false; + } + return [ self::VFLD_DATA => $callback( $oldData, $ttl, $setOpts ), self::VFLD_VERSION => $version -- 2.20.1