(PHP) Undefined Index from existing keys in getMulti result
Hi, we are testing Couchbase and the 1.0.1 (current) PHP SDK on our dev servers and are noticing some strange behavior from the getMulti function: keys which exist and are visible when print_r'ing the response give an undefined index error when we try to access them.
Here's our code:
$couchbase = new Couchbase(COUCHBASE_HOST . ':' . COUCHBASE_PORT); $queryKeys = array('testKey', 'testKey1'); // Delete all the keys and then give them some values foreach ($queryKeys as $currKey) { $couchbase->delete($currKey); $couchbase->set($currKey, 'testVal ' . $currKey); } $multiResult = $GLOBALS['membase']->getMulti($queryKeys); print_r($multiResult); // Shows correct result array print "\n\n"; // Go through the results foreach ($multiResult as $resultKey => $resultValue) { print "result key: $resultKey ; result value: $resultValue \n"; var_dump($resultKey); print "multiResult[$resultKey]: "; var_dump(@$multiResult[$resultKey]); // Undefined index error without @ print "\n"; } print "\n\n------\n\n"; // Go through the keys that we queried couchbase with foreach ($queryKeys as $currKey) { print "query key: $currKey \n"; var_dump($currKey); var_dump(@$multiResult[$currKey]); // Undefined index error without @ }
Here's the output: http://pastebin.com/MASx6v5K
So the problem is that the array that getMulti returns is somehow not accessible by either its own keys (when iterating with a foreach) or the keys used to query couchbase. This always worked fine with libmemcached. Any ideas on what we're doing wrong or what the problem could be?
Thanks
Server details:
Couchbase server: Version: 1.8.0 enterprise edition (build-55)
PHP: 5.3.5
libcouchbase-devel version 1.0.2
libcouchbase1 version 1.0.2
Off the top of my head, I don't see anything incorrect there. Thanks for all of the good info, this should help us track it down quickly.
I've filed http://www.couchbase.com/issues/browse/PCBC-59 and we'll try to look into it. You may want to add yourself to the watch list there to see updates.