andreiz / php-zookeeper

A PHP extension for interfacing with Apache ZooKeeper
Other
449 stars 215 forks source link

Respect null's when passed as values during set(), create(), and get(). #22

Closed ryanuber closed 10 years ago

ryanuber commented 11 years ago

This change set fixes NULL handling in php-zookeeper.

Before (notice my null gets cast to string):

php > $z = new Zookeeper('127.0.0.1:2181');
php > $z->create('/test', null, array(array('perms' => Zookeeper::PERM_ALL, 'scheme' => 'world', 'id' => 'anyone')));
php > var_dump($z->get('/test'));
string(0) ""

After (null is preserved):

php > $z = new Zookeeper('127.0.0.1:2181');
php > $z->create('/test', null, array(array('perms' => Zookeeper::PERM_ALL, 'scheme' => 'world', 'id' => 'anyone')));
php > var_dump($z->get('/test'));
NULL
php >

This patch also fixes a segfault. If there is a znode in your zookeeper server somewhere with a NULL value and you attempt to read it, you get this:

php > var_dump($z->get('/test'));
string(-1) "Segmentation fault

With this patch, this would look more like this:

php > var_dump($z->get('/test'));
NULL
ryanuber commented 11 years ago

Hey @andreiz, If you have any suggestions for improvement, or another solution to this problem, or any other input, I'd really like to know what you think. Thanks!

ziodave commented 10 years ago

Did this fix land in the repo?

andreiz commented 10 years ago

Just merged it.

On Mon, Nov 11, 2013 at 2:54 AM, David Riccitelli notifications@github.comwrote:

Did this fix land in the repo?

— Reply to this email directly or view it on GitHubhttps://github.com/andreiz/php-zookeeper/pull/22#issuecomment-28189692 .