The php7 api has substantial changes in the way one goes about
interacting with the zval type (php's internal structure for dealing
with dynamically typed variables).
Most notably, most everything is dereferenced by one pointer. So,
where you once used zval** you typically use zval*, and where you
used zval* you now just use a zval struct on the stack.
In addition, the api changed in how you return a string. Previously
you had the option of whether or not to "duplicate" the memory returned
(or in other words, pass ownership of the pointer to PHP or not).
Because phpredis sometimes buffers commands to the server (say in the
case of a pipeline, or a MULTI/EXEC) transaction, we had several stack
violations and/or memory corruption which resulted from keeping track
of the address of a stack allocated structure, which was accessed at
a later date (sometimes causing segmentation faults, bus errors, etc).
Also, there were a few places where this pattern was being used:
zval **ptr = emalloc(sizeof(zval*) * count);
/* stuff */
ZVAL_STRING(ptr[0], "hello world");
Given that ZVAL_STRING() thinks it's writing to an allocated structure
it would cause various random issues (because we were blowing through
the data segment and writing into the code section).
This commit (so far) fixes all of the segmentation faults and memory
errors but there are still leaks (specifically in RedisArray) that need
to be solved.
Addresses #727
* Added a test specifically for RedisCluster to test slave failover
settings.
* Added an option to specifically disable colorization, as well as
a mechanism to determine if the output is being piped, such that
we can turn colorization off in that case as well.
This commit reworks the unit tests such that all three classes
(Redis, RedisArray, and RedisCluster) can be tested using the
TestRedis.php script.
Now, when running TestRedis.php an option can be passed for which
part of phpredis we would like to test (defaults to Redis).