Skip to content

Commit 776b7e4

Browse files
committed
Remove igbinary dependency
Change-Id: I19a3782fa9154df97460af2bca9c11cd765f50d8 Reviewed-on: http://review.couchbase.org/120727 Tested-by: Build Bot <[email protected]> Reviewed-by: Sergey Avseyev <[email protected]>
1 parent b5b6737 commit 776b7e4

File tree

6 files changed

+4
-117
lines changed

6 files changed

+4
-117
lines changed

api/couchbase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
* necessary, use `new stdClass()` to persist empty JSON object. Note, that only JSON format considered supported by
1616
* all Couchbase SDKs, everything else is private implementation (i.e. `"php"` format won't be readable by .NET SDK).
1717
* * `"php"` - uses PHP serialize() method to encode the document.
18-
* * `"igbinary"` - uses pecl/igbinary to encode the document in even more efficient than `"php"` format. Might not be
19-
* available, if the Couchbase PHP SDK didn't find it during build phase, in this case constant
20-
* \Couchbase\HAVE_IGBINARY will be false.
2118
*
2219
* * `couchbase.encoder.compression` (string), default: `"none"`
2320
*

config.m4

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,28 +147,4 @@ COUCHBASE_FILES=" \
147147
PHP_ADD_BUILD_DIR($ext_builddir/src/couchbase/bucket_manager, 1)
148148
PHP_ADD_BUILD_DIR($ext_builddir/src/couchbase/cluster_manager, 1)
149149
PHP_ADD_EXTENSION_DEP(couchbase, json)
150-
151-
152-
AC_MSG_CHECKING([for igbinary support])
153-
igbinary_inc_path=""
154-
if test -f "$abs_srcdir/include/php/ext/igbinary/igbinary.h"; then
155-
igbinary_inc_path="$abs_srcdir/include/php"
156-
elif test -f "$abs_srcdir/ext/igbinary/igbinary.h"; then
157-
igbinary_inc_path="$abs_srcdir"
158-
elif test -f "$phpincludedir/ext/session/igbinary.h"; then
159-
igbinary_inc_path="$phpincludedir"
160-
elif test -f "$phpincludedir/ext/igbinary/igbinary.h"; then
161-
igbinary_inc_path="$phpincludedir"
162-
fi
163-
if test "$igbinary_inc_path" = ""; then
164-
AC_MSG_WARN([Cannot find igbinary.h])
165-
else
166-
AC_DEFINE(HAVE_COUCHBASE_IGBINARY,1,[Whether igbinary serializer is enabled])
167-
IGBINARY_INCLUDES="-I$igbinary_inc_path"
168-
ifdef([PHP_ADD_EXTENSION_DEP],
169-
[
170-
PHP_ADD_EXTENSION_DEP(couchbase, igbinary)
171-
])
172-
AC_MSG_RESULT([$igbinary_inc_path])
173-
fi
174150
fi

config.w32

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ if (PHP_COUCHBASE != "no") {
1010
CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)) {
1111
AC_DEFINE("HAVE_COUCHBASE_ZLIB", 1, "Whether zlib compressor is enabled");
1212
}
13-
if (ADD_EXTENSION_DEP('couchbase', 'igbinary')) {
14-
AC_DEFINE("HAVE_COUCHBASE_IGBINARY", 1, "Whether igbinary serializer is enabled");
15-
}
1613

1714
root_sources =
1815
"couchbase.c " +

couchbase.c

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
#include <zlib.h>
2828
#endif
2929

30-
#if HAVE_COUCHBASE_IGBINARY
31-
#include <ext/igbinary/igbinary.h>
32-
#endif
33-
3430
#define LOGARGS(lvl) LCB_LOG_##lvl, NULL, "pcbc/ext", __FILE__, __LINE__
3531

3632
typedef unsigned char uint8_t;
@@ -117,10 +113,6 @@ static PHP_INI_MH(OnUpdateFormat)
117113
PCBCG(enc_format_i) = COUCHBASE_SERTYPE_JSON;
118114
} else if (!strcmp(str_val, "php") || !strcmp(str_val, "PHP")) {
119115
PCBCG(enc_format_i) = COUCHBASE_SERTYPE_PHP;
120-
#ifdef HAVE_COUCHBASE_IGBINARY
121-
} else if (!strcmp(str_val, "igbinary") || !strcmp(str_val, "IGBINARY")) {
122-
PCBCG(enc_format_i) = COUCHBASE_SERTYPE_IGBINARY;
123-
#endif
124116
} else {
125117
return FAILURE;
126118
}
@@ -385,7 +377,6 @@ PHP_MINIT_FUNCTION(couchbase)
385377
PCBC_REGISTER_CONST_RAW(COUCHBASE_VAL_IS_DOUBLE);
386378
PCBC_REGISTER_CONST_RAW(COUCHBASE_VAL_IS_BOOL);
387379
PCBC_REGISTER_CONST_RAW(COUCHBASE_VAL_IS_SERIALIZED);
388-
PCBC_REGISTER_CONST_RAW(COUCHBASE_VAL_IS_IGBINARY);
389380
PCBC_REGISTER_CONST_RAW(COUCHBASE_VAL_IS_JSON);
390381
PCBC_REGISTER_CONST_RAW(COUCHBASE_COMPRESSION_MASK);
391382
PCBC_REGISTER_CONST_RAW(COUCHBASE_COMPRESSION_NONE);
@@ -394,7 +385,6 @@ PHP_MINIT_FUNCTION(couchbase)
394385
PCBC_REGISTER_CONST_RAW(COUCHBASE_COMPRESSION_MCISCOMPRESSED);
395386

396387
PCBC_REGISTER_CONST_RAW(COUCHBASE_SERTYPE_JSON);
397-
PCBC_REGISTER_CONST_RAW(COUCHBASE_SERTYPE_IGBINARY);
398388
PCBC_REGISTER_CONST_RAW(COUCHBASE_SERTYPE_PHP);
399389
PCBC_REGISTER_CONST_RAW(COUCHBASE_CMPRTYPE_NONE);
400390
PCBC_REGISTER_CONST_RAW(COUCHBASE_CMPRTYPE_ZLIB);
@@ -407,8 +397,6 @@ PHP_MINIT_FUNCTION(couchbase)
407397
PCBC_REGISTER_CONST_RAW(COUCHBASE_CFFMT_STRING);
408398

409399
REGISTER_NS_LONG_CONSTANT("Couchbase", "ENCODER_FORMAT_JSON", COUCHBASE_SERTYPE_JSON, CONST_CS | CONST_PERSISTENT);
410-
REGISTER_NS_LONG_CONSTANT("Couchbase", "ENCODER_FORMAT_IGBINARY", COUCHBASE_SERTYPE_IGBINARY,
411-
CONST_CS | CONST_PERSISTENT);
412400
REGISTER_NS_LONG_CONSTANT("Couchbase", "ENCODER_FORMAT_PHP", COUCHBASE_SERTYPE_PHP, CONST_CS | CONST_PERSISTENT);
413401

414402
REGISTER_NS_LONG_CONSTANT("Couchbase", "ENCODER_COMPRESSION_NONE", COUCHBASE_CMPRTYPE_NONE,
@@ -418,11 +406,7 @@ PHP_MINIT_FUNCTION(couchbase)
418406
REGISTER_NS_LONG_CONSTANT("Couchbase", "ENCODER_COMPRESSION_FASTLZ", COUCHBASE_CMPRTYPE_FASTLZ,
419407
CONST_CS | CONST_PERSISTENT);
420408

421-
#ifdef HAVE_COUCHBASE_IGBINARY
422-
REGISTER_NS_LONG_CONSTANT("Couchbase", "HAVE_IGBINARY", 1, CONST_CS | CONST_PERSISTENT);
423-
#else
424409
REGISTER_NS_LONG_CONSTANT("Couchbase", "HAVE_IGBINARY", 0, CONST_CS | CONST_PERSISTENT);
425-
#endif
426410

427411
#ifdef HAVE_COUCHBASE_ZLIB
428412
REGISTER_NS_LONG_CONSTANT("Couchbase", "HAVE_ZLIB", 1, CONST_CS | CONST_PERSISTENT);
@@ -458,12 +442,6 @@ static void basic_encoder_v1(zval *value, int sertype, int cmprtype, long cmprth
458442
zval dtype;
459443
unsigned int flags = 0;
460444

461-
#ifndef HAVE_COUCHBASE_IGBINARY
462-
if (sertype == COUCHBASE_SERTYPE_IGBINARY) {
463-
pcbc_log(LOGARGS(WARN), "igbinary extension is not found, fallback to JSON serializer");
464-
sertype = COUCHBASE_SERTYPE_JSON;
465-
}
466-
#endif
467445
ZVAL_UNDEF(&res);
468446

469447
switch (Z_TYPE_P(value)) {
@@ -544,23 +522,6 @@ static void basic_encoder_v1(zval *value, int sertype, int cmprtype, long cmprth
544522
smart_str_free(&buf);
545523
}
546524
break;
547-
#ifdef HAVE_COUCHBASE_IGBINARY
548-
case COUCHBASE_SERTYPE_IGBINARY:
549-
flags = COUCHBASE_VAL_IS_IGBINARY | COUCHBASE_CFFMT_PRIVATE;
550-
{
551-
uint8_t *buf;
552-
size_t len;
553-
554-
len = 0;
555-
if (igbinary_serialize(&buf, &len, value TSRMLS_CC)) {
556-
pcbc_log(LOGARGS(WARN), "Failed to serialize value with igbinary");
557-
} else {
558-
PCBC_STRINGL(res, (char *)buf, len);
559-
efree(buf);
560-
}
561-
}
562-
break;
563-
#endif
564525
}
565526
}
566527

@@ -777,16 +738,8 @@ static void basic_decoder_v1(char *bytes, size_t bytes_len, unsigned long flags,
777738
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
778739
} break;
779740
case COUCHBASE_VAL_IS_IGBINARY:
780-
#if HAVE_COUCHBASE_IGBINARY
781-
if (igbinary_unserialize((uint8_t *)bytes, bytes_len, &res TSRMLS_CC)) {
782-
pcbc_log(LOGARGS(WARN), "Failed to deserialize value with igbinary");
783-
ZVAL_NULL(&res);
784-
}
785-
break;
786-
#else
787-
pcbc_log(LOGARGS(WARN), "The igbinary extension was not available when the couchbase extension was built.");
741+
pcbc_log(LOGARGS(WARN), "The igbinary serialization is not supported.");
788742
RETURN_NULL();
789-
#endif
790743
default:
791744
pcbc_log(LOGARGS(WARN), "Unknown serialization type: %d", cffmt);
792745
ZVAL_NULL(&res);
@@ -1062,11 +1015,6 @@ static PHP_MINFO_FUNCTION(couchbase)
10621015
php_info_print_table_row(2, "extension version", PHP_COUCHBASE_VERSION);
10631016
php_info_print_table_row(2, "libcouchbase runtime version", buf);
10641017
php_info_print_table_row(2, "libcouchbase headers version", LCB_VERSION_STRING " (git: " LCB_VERSION_CHANGESET ")");
1065-
#ifdef HAVE_COUCHBASE_IGBINARY
1066-
php_info_print_table_row(2, "igbinary transcoder", "enabled");
1067-
#else
1068-
php_info_print_table_row(2, "igbinary transcoder", "disabled (install pecl/igbinary and rebuild pecl/couchbase)");
1069-
#endif
10701018
#ifdef HAVE_COUCHBASE_ZLIB
10711019
php_info_print_table_row(2, "zlib compressor", "enabled");
10721020
#else
@@ -1136,9 +1084,6 @@ static zend_function_entry couchbase_functions[] = {
11361084
#if ZEND_MODULE_API_NO >= 20050617
11371085
static zend_module_dep php_couchbase_deps[] = {
11381086
ZEND_MOD_REQUIRED("json")
1139-
#ifdef HAVE_COUCHBASE_IGBINARY
1140-
ZEND_MOD_REQUIRED("igbinary")
1141-
#endif
11421087
ZEND_MOD_END
11431088
};
11441089
#endif

tests/CouchbaseMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// vim: et ts=4 sw=4 sts=4
33

44
class CouchbaseMock {
5-
const VERSION = '1.5.23';
5+
const VERSION = '1.5.25';
66

77
private $jarPath;
88
private $ctlServer;

xtests/TranscoderTest.php

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ function testCouchbaseBasicEncoderV1() {
118118
$this->assertEquals(COUCHBASE_VAL_IS_DOUBLE, $res[1] & COUCHBASE_VAL_MASK);
119119
$this->assertEquals(["1.0", 0x02000002, 0], $res);
120120

121-
if (\Couchbase\HAVE_IGBINARY) {
122-
$options['sertype'] = COUCHBASE_SERTYPE_IGBINARY;
123-
$res = \Couchbase\basicEncoderV1(["foo" => 0xabcdef0123456789], $options);
124-
$this->assertEquals(COUCHBASE_COMPRESSION_NONE, $res[1] & COUCHBASE_COMPRESSION_MASK);
125-
$this->assertEquals(COUCHBASE_CFFMT_PRIVATE, $res[1] & COUCHBASE_CFFMT_MASK);
126-
$this->assertEquals(COUCHBASE_VAL_IS_IGBINARY, $res[1] & COUCHBASE_VAL_MASK);
127-
$this->assertEquals([hex2bin("0000000214011103666f6f0c43e579bde02468ad"), 0x01000005, 0], $res);
128-
}
129-
130121
$options['sertype'] = COUCHBASE_SERTYPE_JSON;
131122
if (\Couchbase\HAVE_ZLIB) {
132123
$options['cmprtype'] = COUCHBASE_CMPRTYPE_ZLIB;
@@ -279,22 +270,14 @@ function testCouchbaseBasicDecoderV1() {
279270
$this->assertEquals(["foo" => 0xabcdef0123456789], $res);
280271

281272
$res = \Couchbase\basicDecoderV1(hex2bin("0000000214011103666f6f0c43e579bde02468ad"), 0x01000005, 0, $options);
282-
if (\Couchbase\HAVE_IGBINARY) {
283-
$this->assertEquals(["foo" => 0xabcdef0123456789], $res);
284-
} else {
285-
$this->assertEquals(NULL, $res);
286-
}
273+
$this->assertEquals(NULL, $res);
287274

288275
$options['jsonassoc'] = false; // jsonassoc does not affect "binary" encoders
289276
$res = \Couchbase\basicDecoderV1('a:1:{s:3:"foo";d:1.2379813738877118E+19;}', 0x01000004, 0, $options);
290277
$this->assertEquals(["foo" => 0xabcdef0123456789], $res);
291278

292279
$res = \Couchbase\basicDecoderV1(hex2bin("0000000214011103666f6f0c43e579bde02468ad"), 0x01000005, 0, $options);
293-
if (\Couchbase\HAVE_IGBINARY) {
294-
$this->assertEquals(["foo" => 0xabcdef0123456789], $res);
295-
} else {
296-
$this->assertEquals(NULL, $res);
297-
}
280+
$this->assertEquals(NULL, $res);
298281

299282
$res = \Couchbase\basicDecoderV1("1.0", 0x02000002, 0, $options);
300283
$this->assertEquals(1.0, $res);
@@ -331,17 +314,6 @@ function testInvalidInputForPhpSerialize() {
331314
$this->assertNull($res);
332315
}
333316

334-
/**
335-
* @expectedException PHPUnit_Framework_Error
336-
* @expectedExceptionMessageRegExp /igbinary_unserialize_header/
337-
*/
338-
function testInvalidInputForIgbinary() {
339-
if (!\Couchbase\HAVE_IGBINARY) {
340-
$this->markTestSkipped('Extension does not support IGBINARY serializer');
341-
}
342-
\Couchbase\basicDecoderV1(hex2bin("00000214011103666f6f0c43e579bde02468ad"), 0x01000005, 0, []);
343-
}
344-
345317
function testCouchbaseDefaultEncoder() {
346318
$orig = ini_get('couchbase.encoder.format');
347319
ini_set('couchbase.encoder.format', 'json');

0 commit comments

Comments
 (0)