[PCBC-181] The documentation is wrong for get() in couchbase-api.php Created: 17/Jan/13  Updated: 18/Jan/13  Resolved: 18/Jan/13

Status: Resolved
Project: Couchbase PHP client library
Component/s: docs
Affects Version/s: 1.1.2
Fix Version/s: 1.1.3
Security Level: Public

Type: Bug Priority: Major
Reporter: Michael Nitschinger Assignee: Trond Norbye
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment: MacOS X, PHP 5.4


 Description   
I just discovered this while fixing a bug in Basement.

The $cas variable callback is not working on get() but works on getMulti().

Simple example:

Works:
$client->set("foo", "bar");
$cas = null;
var_dump($client->getMulti(array("foo"), $cas));
var_dump($cas);

array(1) {
  ["foo"]=>
  string(3) "bar"
}
array(1) {
  ["foo"]=>
  string(20) "11699665754086047744"
}

Doesn't work:
$client->set("foo", "bar");
$cas = null;
var_dump($client->get("foo", $cas));
var_dump($cas);

string(3) "bar"
NULL

The doc gets returned properly, but the cas value is not set. Also, when you set $cas to "" or false (not null), then it complains with a dubios error:
Warning: Couchbase::get() expects parameter 2 to be a valid callback, no array or string given in /Users/michael/Webserver/basement-test/index.php on line 10
Note that its a warning and not an exception on the OOP interface!


 Comments   
Comment by Michael Nitschinger [ 17/Jan/13 ]
Okay after more investigation of course the notation is:

get(key, callback, cas)

then only the documentation needs to be updated here:

https://github.com/couchbase/php-ext-couchbase/blob/master/example/couchbase-api.php#L320
Comment by Trond Norbye [ 18/Jan/13 ]
http://review.couchbase.org/#/c/24053/
Generated at Sat Oct 25 02:06:54 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.