Read full memcached response before manipulating data
authorMatthias Mullie <git@mullie.eu>
Mon, 4 Feb 2013 16:54:53 +0000 (17:54 +0100)
committerMatthias Mullie <git@mullie.eu>
Thu, 7 Mar 2013 14:59:10 +0000 (15:59 +0100)
commita8f00e5c9738447063f87f5c704e7a99becd9219
tree3ed5d15a031cf7a0020cccfd0181a7ce3ff31c09
parent74667197d687d5c51fee371bbcfba14aaafc5e27
Read full memcached response before manipulating data

Memcached response when fetching data typically looks like this:
VALUE <the stored value for whatever key you requested>
END

What the code used to do is read the first line (the VALUE) and re-
assemble the data being fetched there (like unserializing serialized
data). After that, it will read the next line (END).

The value could be a serialized object, which could have a __wakeup.
This __wakeup could have code which in turn executes Memcached-
related stuff. The problem is that, while that object is being
unserialized already, it's wakeup code is attempting to read new
stuff from Memcached, but we have yet to read the END of the data
we're attempting to unserialize (when we'll read a new value from
Memcached, the first thing we'd get is the END we have not yet read..)

The correct way to go about this would be to first read the full
Memcached response, and only unserialize the read data after that.
This is exactly what this patchset does.

Change-Id: I902809c6dde657091c8161a09df823170bd41f7a
includes/objectcache/MemcachedClient.php
tests/phpunit/includes/objectcache/BagOStuffTest.php