Aaron Schulz has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393517 )

Change subject: objectcache: do not send old version values to 
getWithSetCallback() callbacks
......................................................................

objectcache: do not send old version values to getWithSetCallback() callbacks

The code might not be able to handle missing, new, or changed fields
if it happens to use $oldValue. Avoid making that assumption.

Change-Id: If108a73078c530c985d30bdadcbfa9ddd53dc2be
---
M includes/libs/objectcache/WANObjectCache.php
1 file changed, 4 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/17/393517/1

diff --git a/includes/libs/objectcache/WANObjectCache.php 
b/includes/libs/objectcache/WANObjectCache.php
index f5c561f..2c7beff 100644
--- a/includes/libs/objectcache/WANObjectCache.php
+++ b/includes/libs/objectcache/WANObjectCache.php
@@ -899,25 +899,17 @@
                                $cur = $this->doGetWithSetCallback(
                                        $key,
                                        $ttl,
-                                       function ( $oldValue, &$ttl, &$setOpts, 
$oldAsOf )
-                                       use ( $callback, $version ) {
-                                               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;
-                                               }
-
+                                       function ( $oldValue, &$ttl, &$setOpts 
) use ( $callback, $version ) {
+                                               // Do not send an old version 
value to a newer version callback
                                                return [
-                                                       self::VFLD_DATA => 
$callback( $oldData, $ttl, $setOpts, $oldAsOf ),
+                                                       self::VFLD_DATA => 
$callback( false, $ttl, $setOpts, null ),
                                                        self::VFLD_VERSION => 
$version
                                                ];
                                        },
                                        $opts,
                                        $asOf
                                );
+
                                if ( $cur[self::VFLD_VERSION] === $version ) {
                                        // Value created or existed before with 
version; use it
                                        $value = $cur[self::VFLD_DATA];

-- 
To view, visit https://gerrit.wikimedia.org/r/393517
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If108a73078c530c985d30bdadcbfa9ddd53dc2be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to