The following code does not give expected results :
<?php
$var = 'crash__'.getmypid().'_'.time();
$cluster = new CouchbaseCluster('couchbase://10.0.0.100','test','');
$bucket = $cluster->openBucket('test');
$bucket->insert($var,'Hello');
$resp = $bucket->append($var,' World');
var_dump($resp); // expecting a CAS ressource but got NULL instead
$resp = $bucket->get($var);
var_dump($resp->value); // expecting "Hello World" but got "Hello" instead
My guess is the line 111 in the libcouchbase file : src/operations/store.c :
case LCB_APPEND:
case LCB_PREPEND:
if (cmd->exptime || cmd->flags) {
return LCB_OPTIONS_CONFLICT;
}
break;
If flags is set then the function aborts. And the PHP library does send a flag.
I was able to workaround the bug by changing the encoder with the method $bucket->setTranscoder() and by providing a PHP function identical to the one provided in the php-couchbase sources in file stub/default_transcoder.php but for the fact that it sets the flag to 0.
The couchbase cluster i used for testing has only 1 node.
The server is Couchbase CE 3.0.1.
This was reproduced on 2 clients with different configurations :
OS : Ubuntu 12.04 32bit - Linux 3.5.0-54-generic #81~precise1-Ubuntu SMP Tue Jul 15 04:05:58 UTC 2014 i686 i686 i386 GNU/Linux
PHP :
PHP 5.3.10-1ubuntu3.15 with Suhosin-Patch (cli) (built: Oct 29 2014 12:16:30)
Copyright © 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright © 1998-2012 Zend Technologies
PHP module : 2.0.2 from "deb http://packages.couchbase.com/ubuntu precise precise/main"
libcouchbase : 2.4.5
and :
OS : Debian 7 64bit - Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux
PHP :
PHP 5.3.29-1~dotdeb.0 with Suhosin-Patch (cli) (built: Aug 14 2014 19:55:20)
Copyright © 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright © 1998-2014 Zend Technologies
PHP module : 2.0.2
libcouchbase : 2.4.3