Apologies if this is the wrong place for this, I couldn’t see how to report an issue via JIRA.
I think there is a bug in the v2 PHP SDK when fetching multiple documents by IDs using an associative array.
I’m using version 2.0.3 of the PHP SDK, and Couchbase version 3.0.2.
Here’s some code demonstrating the problem:
$couch = new \CouchbaseCluster('couchbase://127.0.0.1');
$bucket = $couch->openBucket('my_bucket', 'my_password');
$ids = ['foo' => 'doc1', 'bar' => 'doc2'];
print_r($bucket->get($ids));
print_r($bucket->get(array_values($ids)));
The result from the first print_r call is indexed using the keys from my input array, but contains only errors:
...
[foo] => CouchbaseMetaDoc Object
(
[error] => CouchbaseException Object
(
[message:protected] => The key does not exist on the server
...
[value] =>
[flags] =>
[cas] =>
[bar] => CouchbaseMetaDoc Object
(
[error] => CouchbaseException Object
(
[message:protected] => The key does not exist on the server
...
[value] =>
[flags] =>
[cas] =>
...
However the second call which converts the array to be numerically indexed results in the expected result:
...
[doc1] => CouchbaseMetaDoc Object
(
[error] =>
[value] => <the document>
[flags] => 67108864
[cas] => Resource id #317
)
[doc2] => CouchbaseMetaDoc Object
(
[error] =>
[value] => <the document>
[flags] => 67108864
[cas] => Resource id #318
)
...
Obviously this is easily worked around, but is probably better addressed in the \CouchbaseBucket class’ get() method.