Skip to content

Commit

Permalink
Merge branch 'php7' into exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Nov 6, 2016
2 parents 3001ef5 + fe0d0af commit 4ce0fc3
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
language: php
php:
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
- 5.3

env:
- LIBZOOKEEPER_VERSION=3.5.0-alpha
- LIBZOOKEEPER_VERSION=3.4.6
- LIBZOOKEEPER_VERSION=3.5.2-alpha
- LIBZOOKEEPER_VERSION=3.4.8

addons:
apt:
Expand Down
2 changes: 1 addition & 1 deletion .travis/install_libzookeeper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LIBZOOKEEPER_VERSION=$1
PACKAGE_NAME=zookeeper-${LIBZOOKEEPER_VERSION}
LIBZOOKEEPER_PREFIX=${HOME}/lib${PACKAGE_NAME}

wget http://apache.fayea.com/zookeeper/${PACKAGE_NAME}/${PACKAGE_NAME}.tar.gz || exit 1
wget http://apache.mirrors.lucidnetworks.net/zookeeper/${PACKAGE_NAME}/${PACKAGE_NAME}.tar.gz || exit 1
tar xvf ${PACKAGE_NAME}.tar.gz || exit 1
mv ${PACKAGE_NAME}/conf/zoo_sample.cfg ${PACKAGE_NAME}/conf/zoo.cfg
${PACKAGE_NAME}/bin/zkServer.sh start
Expand Down
21 changes: 21 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
zookeeper extension changelog

Version 0.2.3
-------------
Bugs:
* Fix 'Node with null data cause php segfault at Zookeeper::get($path)' (AZ Issue #21)
* Fix 'Stat is null when get a node which holds null data' (AZ Issue #29)
* Fix 'Wrong type conversion in function call' (Thanks to Dmitry Faleychik<fadimko@gmail.com>, AZ PR #42)
* Fix AZ PR #44 (Thanks to jeff.tang<likeytom@gmail.com>)
* Fix AZ Issue #27 (--with-libdir not honoured, Thanks to Remi Collet)

Improvements:
* Respect null's when passed as values during set(), create(), and get() (Thanks to Ryan Uber<ru@ryanuber.com>, AZ PR #22)
* Make extension compatible with Zookeeper 3.5.0alpha (Thanks to Ryan Uber<ru@ryanuber.com>, AZ PR #28 N #48)
* Display ini entries in `phpinfo()`


Version 0.2.2
-------------
* PHP 5.4 compatibility
Expand All @@ -10,9 +25,15 @@ Version 0.2.2
Version 0.2.1
-------------

* Package up missed source files

Version 0.2.0
-------------

* Added session handler support
* Added connect() and delete methods
* Bug fixes

Version 0.1.0
-------------
* Initial release
5 changes: 3 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Description
-----------

[![Build Status](https://img.shields.io/travis/andreiz/php-zookeeper/master.svg?style=flat-square)](https://travis-ci.org/andreiz/php-zookeeper)
[![Build Status](https://img.shields.io/travis/php-zookeeper/php-zookeeper/master.svg?style=flat-square)](https://travis-ci.org/andreiz/php-zookeeper)
[![Coveralls](https://img.shields.io/coveralls/andreiz/php-zookeeper.svg?style=flat-square)](https://coveralls.io/r/andreiz/php-zookeeper?branch=master)

This extension uses libzookeeper library to provide API for communicating with
Expand All @@ -13,5 +13,6 @@ providing group services.

Resources
---------
* [zookeeper](http://hadoop.apache.org/zookeeper/)
* [zookeeper](https://zookeeper.apache.org/)
* [recipes](https://github.com/Gutza/php-zookeeper-recipes)
* [admin](https://github.com/Timandes/zookeeper-admin)
53 changes: 48 additions & 5 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,33 @@ http://pear.php.net/dtd/package-2.0.xsd">
<email>andrei@php.net</email>
<active>yes</active>
</lead>
<date>2012-01-13</date>
<lead>
<name>Timandes White</name>
<user>timandes</user>
<email>timandes@php.net</email>
<active>yes</active>
</lead>
<date>2016-11-07</date>
<version>
<release>0.2.1</release>
<api>0.2.0</api>
<release>0.2.3</release>
<api>0.2.3</api>
</version>
<stability>
<release>beta</release>
<release>stable</release>
<api>beta</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
- Package up missed source files
- PHP 5.4 compatibility
- Sample PHP class for using zookeeper
- Fix NOTCONNECTED_STATE issue
- Various other fixes
</notes>
<contents>
<dir name="/">
<dir name="examples">
<file role='doc' name='Zookeeper_Example.php'/>
</dir>
<file role='doc' name='README.markdown'/>
<file role='doc' name='CREDITS'/>
<file role='doc' name='LICENSE'/>
Expand Down Expand Up @@ -60,6 +72,37 @@ http://pear.php.net/dtd/package-2.0.xsd">
<providesextension>zookeeper</providesextension>
<extsrcrelease/>
<changelog>
<release>
<stability><release>stable</release><api>beta</api></stability>
<version><release>0.2.3</release><api>0.2.3</api></version>
<date>2016-11-07</date>
<notes><![CDATA[
Bugs:
- Fix 'Node with null data cause php segfault at Zookeeper::get($path)' (AZ Issue #21)
- Fix 'Stat is null when get a node which holds null data' (AZ Issue #29)
- Fix 'Wrong type conversion in function call' (Thanks to Dmitry Faleychik<fadimko@gmail.com>, AZ PR #42)
- Fix AZ PR #44 (Thanks to jeff.tang<likeytom@gmail.com>)
- Fix AZ Issue #27 (--with-libdir not honoured, Thanks to Remi Collet)
Improvements:
- Respect null's when passed as values during set(), create(), and get() (Thanks to Ryan Uber<ru@ryanuber.com>, AZ PR #22)
- Make extension compatible with Zookeeper 3.5.0alpha (Thanks to Ryan Uber<ru@ryanuber.com>, AZ PR #28 N #48)
- Display ini entries in `phpinfo()`
]]></notes>
</release>

<release>
<stability><release>beta</release><api>beta</api></stability>
<version><release>0.2.2</release><api>0.2.2</api></version>
<date>2013-07-30</date>
<notes>
- PHP 5.4 compatibility
- Sample PHP class for using zookeeper
- Fix NOTCONNECTED_STATE issue
- Various other fixes
</notes>
</release>

<release>
<stability><release>beta</release><api>beta</api></stability>
<version><release>0.2.1</release><api>0.2.0</api></version>
Expand Down
16 changes: 12 additions & 4 deletions php_zookeeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ static PHP_METHOD(Zookeeper, get)

ZK_METHOD_FETCH_OBJECT;

#ifdef ZEND_ENGINE_3
if (stat_info) {
ZVAL_DEREF(stat_info);
}
#endif

if (fci.size != 0) {
cb_data = php_cb_data_new(&fci, &fcc, 1 TSRMLS_CC);
}
Expand All @@ -371,8 +377,13 @@ static PHP_METHOD(Zookeeper, get)
length = max_size;
}

if (length <= 0) /* znode carries a NULL */
if (length <= 0) {/* znode carries a NULL */
if (stat_info) {
php_stat_to_array(&stat, stat_info);
}

RETURN_NULL();
}

buffer = emalloc (length+1);
status = zoo_wget(i_obj->zk, path, (fci.size != 0) ? php_zk_watcher_marshal : NULL,
Expand All @@ -392,9 +403,6 @@ static PHP_METHOD(Zookeeper, get)
}

if (stat_info) {
#ifdef ZEND_ENGINE_3
ZVAL_DEREF(stat_info);
#endif
php_stat_to_array(&stat, stat_info);
}

Expand Down
8 changes: 5 additions & 3 deletions php_zookeeper_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ PS_READ_FUNC(zookeeper)
retry_count++;
} while (status == ZCONNECTIONLOSS && retry_count--);

if (status != ZOK) {
if (status == ZNONODE) {
goto error;
} else if (status != ZOK) {
return FAILURE;
}

expiration_time = (int64_t) (SG(global_request_time) - PS(gc_maxlifetime)) * 1000;
Expand All @@ -248,7 +250,7 @@ PS_READ_FUNC(zookeeper)

if (status != ZOK) {
efree(rbuf);
goto error;
return FAILURE;
}

#ifdef ZEND_ENGINE_3
Expand All @@ -267,7 +269,7 @@ PS_READ_FUNC(zookeeper)
*val = NULL;
*vallen = 0;
#endif
return FAILURE;
return SUCCESS; //FAILURE;
#undef SESSKEY
}
/* }}} */
Expand Down
26 changes: 26 additions & 0 deletions tests/gh-az-issue-29.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
AndreiZ/php-zookeeper's issue #29
--SKIPIF--
<?php
if (!extension_loaded('zookeeper')) {
echo 'Zookeeper extension is not loaded';
}
--FILE--
<?php
$path = '/test_az_issue_29';
$acls = array(
array(
'perms' => Zookeeper::PERM_ALL,
'scheme' => 'world',
'id' => 'anyone'
)
);
$zk = new Zookeeper('localhost:2181');
$zk->create($path, null, $acls);
$stats = array();
$zk->get($path, NULL, $stats);
var_dump($stats['dataLength']);
$zk->delete($path);

--EXPECT--
int(0)

0 comments on commit 4ce0fc3

Please sign in to comment.