Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9138299

Browse files
committed
Enable conditional compilation for igbinary option
1 parent b58b176 commit 9138299

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

library.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifdef HAVE_CONFIG_H
2+
#include "config.h"
3+
#endif
14
#include "common.h"
25
#include "php_network.h"
36
#include <sys/types.h>
@@ -7,8 +10,9 @@
710
#endif
811
#include <ext/standard/php_smart_str.h>
912
#include <ext/standard/php_var.h>
10-
13+
#ifdef HAVE_REDIS_IGBINARY
1114
#include "igbinary/igbinary.h"
15+
#endif
1216
#include <zend_exceptions.h>
1317
#include "php_redis.h"
1418
#include "library.h"
@@ -1300,11 +1304,13 @@ redis_serialize(RedisSock *redis_sock, zval *z, char **val, int *val_len TSRMLS_
13001304
return 1;
13011305

13021306
case REDIS_SERIALIZER_IGBINARY:
1307+
#ifdef HAVE_REDIS_IGBINARY
13031308
if(igbinary_serialize(&val8, (size_t *)&sz, z TSRMLS_CC) == 0) { /* ok */
13041309
*val = (char*)val8;
13051310
*val_len = (int)sz;
13061311
return 1;
13071312
}
1313+
#endif
13081314
return 0;
13091315
}
13101316
return 0;
@@ -1345,13 +1351,15 @@ redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval **re
13451351
return ret;
13461352

13471353
case REDIS_SERIALIZER_IGBINARY:
1354+
#ifdef HAVE_REDIS_IGBINARY
13481355
if(!*return_value) {
13491356
MAKE_STD_ZVAL(*return_value);
13501357
}
13511358
if(igbinary_unserialize((const uint8_t *)val, (size_t)val_len, return_value TSRMLS_CC) == 0) {
13521359
return 1;
13531360
}
13541361
efree(*return_value);
1362+
#endif
13551363
return 0;
13561364
break;
13571365
}

redis.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@ PHP_MINIT_FUNCTION(redis)
434434
/* serializer */
435435
add_constant_long(redis_ce, "SERIALIZER_NONE", REDIS_SERIALIZER_NONE);
436436
add_constant_long(redis_ce, "SERIALIZER_PHP", REDIS_SERIALIZER_PHP);
437+
#ifdef HAVE_REDIS_IGBINARY
437438
add_constant_long(redis_ce, "SERIALIZER_IGBINARY", REDIS_SERIALIZER_IGBINARY);
439+
#endif
438440

439441
zend_declare_class_constant_stringl(redis_ce, "AFTER", 5, "after", 5 TSRMLS_CC);
440442
zend_declare_class_constant_stringl(redis_ce, "BEFORE", 6, "before", 6 TSRMLS_CC);
@@ -5653,7 +5655,11 @@ PHP_METHOD(Redis, setOption) {
56535655
switch(option) {
56545656
case REDIS_OPT_SERIALIZER:
56555657
val_long = atol(val_str);
5656-
if(val_long == REDIS_SERIALIZER_NONE || val_long == REDIS_SERIALIZER_IGBINARY || val_long == REDIS_SERIALIZER_PHP) {
5658+
if(val_long == REDIS_SERIALIZER_NONE
5659+
#ifdef HAVE_REDIS_IGBINARY
5660+
|| val_long == REDIS_SERIALIZER_IGBINARY
5661+
#endif
5662+
|| val_long == REDIS_SERIALIZER_PHP) {
56575663
redis_sock->serializer = val_long;
56585664
RETURN_TRUE;
56595665
} else {

0 commit comments

Comments
 (0)