scottmac Thu, 19 May 2011 17:41:21 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=311264
Log:
Tidy up ldap paging code and rename the API as discussed in #42060
Bug: http://bugs.php.net/42060 (Feedback) [PATCH] LDAP: Add pagedResults
support and more
Changed paths:
U php/php-src/branches/PHP_5_4/ext/ldap/ldap.c
A
php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation1.phpt
A
php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation2.phpt
A
php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation3.phpt
D
php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt
D
php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt
D
php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt
U php/php-src/trunk/ext/ldap/ldap.c
A
php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation1.phpt
A
php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation2.phpt
A
php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation3.phpt
D php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt
D php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt
D php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt
Modified: php/php-src/branches/PHP_5_4/ext/ldap/ldap.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/ldap/ldap.c 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/branches/PHP_5_4/ext/ldap/ldap.c 2011-05-19 17:41:21 UTC (rev 311264)
@@ -2186,13 +2186,15 @@
#endif
#ifdef LDAP_CONTROL_PAGEDRESULTS
-/* {{{ proto bool ldap_ctrl_paged_results(resource link, int pagesize [, bool iscritical [, string cookie]])
+/* {{{ proto bool ldap_control_paged_result(resource link, int pagesize [, bool iscritical [, string cookie]])
Inject paged results control*/
-PHP_FUNCTION(ldap_ctrl_paged_results)
+PHP_FUNCTION(ldap_control_paged_result)
{
long pagesize;
zend_bool iscritical;
- zval *link, *cookie;
+ zval *link;
+ char *cookie = NULL;
+ int cookie_len = 0;
struct berval lcookie = { 0, NULL };
ldap_linkdata *ld;
LDAP *ldap;
@@ -2200,11 +2202,11 @@
LDAPControl ctrl, *ctrlsp[2];
int rc, myargcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|bz", &link, &pagesize, &iscritical, &cookie) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|bs", &link, &pagesize, &iscritical, &cookie, &cookie_len) != SUCCESS) {
return;
}
- if (Z_TYPE_PP(&link) == IS_NULL) {
+ if (Z_TYPE_P(link) == IS_NULL) {
ldap = NULL;
} else {
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
@@ -2221,9 +2223,8 @@
switch (myargcount) {
case 4:
- convert_to_string_ex(&cookie);
- lcookie.bv_val = Z_STRVAL_PP(&cookie);
- lcookie.bv_len = Z_STRLEN_PP(&cookie);
+ lcookie.bv_val = cookie;
+ lcookie.bv_len = cookie_len;
/* fallthru */
case 3:
ctrl.ldctl_iscritical = (int)iscritical;
@@ -2232,13 +2233,13 @@
if (ber_printf(ber, "{iO}", (int)pagesize, &lcookie) == LBER_ERROR) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to BER printf paged results control");
- RETVAL_BOOL(0);
+ RETVAL_FALSE;
goto lcpr_error_out;
}
rc = ber_flatten2(ber, &ctrl.ldctl_value, 0);
if (rc == LBER_ERROR) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to BER encode paged results control");
- RETVAL_BOOL(0);
+ RETVAL_FALSE;
goto lcpr_error_out;
}
@@ -2252,16 +2253,16 @@
rc = ldap_set_option(ldap, LDAP_OPT_SERVER_CONTROLS, ctrlsp);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set paged results control: %s (%d)", ldap_err2string(rc), rc);
- RETVAL_BOOL(0);
+ RETVAL_FALSE;
goto lcpr_error_out;
}
- RETVAL_BOOL(1);
+ RETVAL_TRUE;
} else {
/* return a PHP control object */
array_init(return_value);
add_assoc_string(return_value, "oid", ctrl.ldctl_oid, 1);
- if ( ctrl.ldctl_value.bv_len ) {
+ if (ctrl.ldctl_value.bv_len) {
add_assoc_stringl(return_value, "value", ctrl.ldctl_value.bv_val, ctrl.ldctl_value.bv_len, 1);
}
if (ctrl.ldctl_iscritical) {
@@ -2270,16 +2271,16 @@
}
lcpr_error_out:
- if (ber != NULL) {
+ if (ber != NULL) {
ber_free(ber, 1);
}
return;
}
/* }}} */
-/* {{{ proto bool ldap_ctrl_paged_results_resp(resource link, resource result [, string cookie [, int estimated]])
+/* {{{ proto bool ldap_control_paged_result_response(resource link, resource result [, string cookie [, int estimated]])
Extract paged results control response */
-PHP_FUNCTION(ldap_ctrl_paged_results_resp)
+PHP_FUNCTION(ldap_control_paged_result_response)
{
zval *link, *result, *cookie, *estimated;
struct berval lcookie;
@@ -2357,8 +2358,8 @@
zval_dtor(estimated);
ZVAL_LONG(estimated, lestimated);
}
+
zval_dtor(cookie);
-
if (lcookie.bv_len == 0) {
ZVAL_EMPTY_STRING(cookie);
} else {
@@ -2551,14 +2552,14 @@
ZEND_END_ARG_INFO()
#ifdef LDAP_CONTROL_PAGEDRESULTS
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_ctrl_paged_results, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_control_paged_result, 0, 0, 2)
ZEND_ARG_INFO(0, link)
ZEND_ARG_INFO(0, pagesize)
ZEND_ARG_INFO(0, iscritical)
ZEND_ARG_INFO(0, cookie)
ZEND_END_ARG_INFO();
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_ctrl_paged_results_resp, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_control_paged_result_response, 0, 0, 2)
ZEND_ARG_INFO(0, link)
ZEND_ARG_INFO(0, result)
ZEND_ARG_INFO(1, cookie)
@@ -2709,8 +2710,8 @@
#endif
#ifdef LDAP_CONTROL_PAGEDRESULTS
- PHP_FE(ldap_ctrl_paged_results, arginfo_ldap_ctrl_paged_results)
- PHP_FE(ldap_ctrl_paged_results_resp, arginfo_ldap_ctrl_paged_results_resp)
+ PHP_FE(ldap_control_paged_result, arginfo_ldap_control_paged_result)
+ PHP_FE(ldap_control_paged_result_response, arginfo_ldap_control_paged_result_response)
#endif
{NULL, NULL, NULL}
};
Added: php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation1.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation1.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation1.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -0,0 +1,56 @@
+--TEST--
+ldap_ldap_control_paged_results() test (fetching the first page)
+--CREDITS--
+Jean-Sebastien Hedde <[email protected]>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifbindfailure.inc');
+?>
+--FILE--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link);
+
+$dn = "dc=my-domain,dc=com";
+$filter = "(cn=*)";
+var_dump(
+ ldap_control_paged_results($link, 1),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result)
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+remove_dummy_data($link);
+?>
+--EXPECTF--
+bool(true)
+resource(6) of type (ldap result)
+array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userA"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userA,dc=my-domain,dc=com"
+ }
+}
+===DONE===
Added: php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation2.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation2.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation2.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -0,0 +1,72 @@
+--TEST--
+ldap_ldap_control_paged_results() test (fetching the first page with a pagesize=2)
+--CREDITS--
+Jean-Sebastien Hedde <[email protected]>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifbindfailure.inc');
+?>
+--FILE--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link);
+
+$dn = "dc=my-domain,dc=com";
+$filter = "(cn=*)";
+var_dump(
+ ldap_control_paged_results($link, 2),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result)
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+remove_dummy_data($link);
+?>
+--EXPECTF--
+bool(true)
+resource(6) of type (ldap result)
+array(3) {
+ ["count"]=>
+ int(2)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userA"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userA,dc=my-domain,dc=com"
+ }
+ [1]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userB"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userB,dc=my-domain,dc=com"
+ }
+}
+===DONE===
Added: php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation3.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation3.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_control_paged_results_variation3.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -0,0 +1,100 @@
+--TEST--
+ldap_ldap_control_paged_results() test (fetching the first page then the next final page)
+--CREDITS--
+Jean-Sebastien Hedde <[email protected]>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifbindfailure.inc');
+?>
+--FILE--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link);
+
+$dn = "dc=my-domain,dc=com";
+$filter = "(cn=*)";
+$cookie = '';
+var_dump(
+ ldap_control_paged_results($link, 2, true, $cookie),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result),
+ ldap_control_paged_results_response($link, $result, $cookie),
+ ldap_control_paged_results($link, 20, true, $cookie),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result)
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+remove_dummy_data($link);
+?>
+--EXPECTF--
+bool(true)
+resource(%d) of type (ldap result)
+array(3) {
+ ["count"]=>
+ int(2)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userA"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userA,dc=my-domain,dc=com"
+ }
+ [1]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userB"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userB,dc=my-domain,dc=com"
+ }
+}
+bool(true)
+bool(true)
+resource(%d) of type (ldap result)
+array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userC"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
+ }
+}
+===DONE===
Deleted: php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -1,56 +0,0 @@
---TEST--
-ldap_ldap_ctrl_paged_results() test (fetching the first page)
---CREDITS--
-Jean-Sebastien Hedde <[email protected]>
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifbindfailure.inc');
-?>
---FILE--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-insert_dummy_data($link);
-
-$dn = "dc=my-domain,dc=com";
-$filter = "(cn=*)";
-var_dump(
- ldap_ctrl_paged_results($link, 1),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result)
-);
-?>
-===DONE===
---CLEAN--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-remove_dummy_data($link);
-?>
---EXPECTF--
-bool(true)
-resource(6) of type (ldap result)
-array(2) {
- ["count"]=>
- int(1)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userA"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userA,dc=my-domain,dc=com"
- }
-}
-===DONE===
Deleted: php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -1,72 +0,0 @@
---TEST--
-ldap_ldap_ctrl_paged_results() test (fetching the first page with a pagesize=2)
---CREDITS--
-Jean-Sebastien Hedde <[email protected]>
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifbindfailure.inc');
-?>
---FILE--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-insert_dummy_data($link);
-
-$dn = "dc=my-domain,dc=com";
-$filter = "(cn=*)";
-var_dump(
- ldap_ctrl_paged_results($link, 2),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result)
-);
-?>
-===DONE===
---CLEAN--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-remove_dummy_data($link);
-?>
---EXPECTF--
-bool(true)
-resource(6) of type (ldap result)
-array(3) {
- ["count"]=>
- int(2)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userA"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userA,dc=my-domain,dc=com"
- }
- [1]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userB"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userB,dc=my-domain,dc=com"
- }
-}
-===DONE===
Deleted: php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/branches/PHP_5_4/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -1,100 +0,0 @@
---TEST--
-ldap_ldap_ctrl_paged_results() test (fetching the first page then the next final page)
---CREDITS--
-Jean-Sebastien Hedde <[email protected]>
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifbindfailure.inc');
-?>
---FILE--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-insert_dummy_data($link);
-
-$dn = "dc=my-domain,dc=com";
-$filter = "(cn=*)";
-$cookie = '';
-var_dump(
- ldap_ctrl_paged_results($link, 2, true, $cookie),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result),
- ldap_ctrl_paged_results_resp($link, $result, $cookie),
- ldap_ctrl_paged_results($link, 20, true, $cookie),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result)
-);
-?>
-===DONE===
---CLEAN--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-remove_dummy_data($link);
-?>
---EXPECTF--
-bool(true)
-resource(%d) of type (ldap result)
-array(3) {
- ["count"]=>
- int(2)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userA"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userA,dc=my-domain,dc=com"
- }
- [1]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userB"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userB,dc=my-domain,dc=com"
- }
-}
-bool(true)
-bool(true)
-resource(%d) of type (ldap result)
-array(2) {
- ["count"]=>
- int(1)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userC"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
- }
-}
-===DONE===
Modified: php/php-src/trunk/ext/ldap/ldap.c
===================================================================
--- php/php-src/trunk/ext/ldap/ldap.c 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/trunk/ext/ldap/ldap.c 2011-05-19 17:41:21 UTC (rev 311264)
@@ -2186,13 +2186,15 @@
#endif
#ifdef LDAP_CONTROL_PAGEDRESULTS
-/* {{{ proto bool ldap_ctrl_paged_results(resource link, int pagesize [, bool iscritical [, string cookie]])
+/* {{{ proto bool ldap_control_paged_result(resource link, int pagesize [, bool iscritical [, string cookie]])
Inject paged results control*/
-PHP_FUNCTION(ldap_ctrl_paged_results)
+PHP_FUNCTION(ldap_control_paged_result)
{
long pagesize;
zend_bool iscritical;
- zval *link, *cookie;
+ zval *link;
+ char *cookie = NULL;
+ int cookie_len = 0;
struct berval lcookie = { 0, NULL };
ldap_linkdata *ld;
LDAP *ldap;
@@ -2200,11 +2202,11 @@
LDAPControl ctrl, *ctrlsp[2];
int rc, myargcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|bz", &link, &pagesize, &iscritical, &cookie) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|bs", &link, &pagesize, &iscritical, &cookie, &cookie_len) != SUCCESS) {
return;
}
- if (Z_TYPE_PP(&link) == IS_NULL) {
+ if (Z_TYPE_P(link) == IS_NULL) {
ldap = NULL;
} else {
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
@@ -2221,9 +2223,8 @@
switch (myargcount) {
case 4:
- convert_to_string_ex(&cookie);
- lcookie.bv_val = Z_STRVAL_PP(&cookie);
- lcookie.bv_len = Z_STRLEN_PP(&cookie);
+ lcookie.bv_val = cookie;
+ lcookie.bv_len = cookie_len;
/* fallthru */
case 3:
ctrl.ldctl_iscritical = (int)iscritical;
@@ -2232,13 +2233,13 @@
if (ber_printf(ber, "{iO}", (int)pagesize, &lcookie) == LBER_ERROR) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to BER printf paged results control");
- RETVAL_BOOL(0);
+ RETVAL_FALSE;
goto lcpr_error_out;
}
rc = ber_flatten2(ber, &ctrl.ldctl_value, 0);
if (rc == LBER_ERROR) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to BER encode paged results control");
- RETVAL_BOOL(0);
+ RETVAL_FALSE;
goto lcpr_error_out;
}
@@ -2252,16 +2253,16 @@
rc = ldap_set_option(ldap, LDAP_OPT_SERVER_CONTROLS, ctrlsp);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set paged results control: %s (%d)", ldap_err2string(rc), rc);
- RETVAL_BOOL(0);
+ RETVAL_FALSE;
goto lcpr_error_out;
}
- RETVAL_BOOL(1);
+ RETVAL_TRUE;
} else {
/* return a PHP control object */
array_init(return_value);
add_assoc_string(return_value, "oid", ctrl.ldctl_oid, 1);
- if ( ctrl.ldctl_value.bv_len ) {
+ if (ctrl.ldctl_value.bv_len) {
add_assoc_stringl(return_value, "value", ctrl.ldctl_value.bv_val, ctrl.ldctl_value.bv_len, 1);
}
if (ctrl.ldctl_iscritical) {
@@ -2270,16 +2271,16 @@
}
lcpr_error_out:
- if (ber != NULL) {
+ if (ber != NULL) {
ber_free(ber, 1);
}
return;
}
/* }}} */
-/* {{{ proto bool ldap_ctrl_paged_results_resp(resource link, resource result [, string cookie [, int estimated]])
+/* {{{ proto bool ldap_control_paged_result_response(resource link, resource result [, string cookie [, int estimated]])
Extract paged results control response */
-PHP_FUNCTION(ldap_ctrl_paged_results_resp)
+PHP_FUNCTION(ldap_control_paged_result_response)
{
zval *link, *result, *cookie, *estimated;
struct berval lcookie;
@@ -2357,8 +2358,8 @@
zval_dtor(estimated);
ZVAL_LONG(estimated, lestimated);
}
+
zval_dtor(cookie);
-
if (lcookie.bv_len == 0) {
ZVAL_EMPTY_STRING(cookie);
} else {
@@ -2551,14 +2552,14 @@
ZEND_END_ARG_INFO()
#ifdef LDAP_CONTROL_PAGEDRESULTS
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_ctrl_paged_results, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_control_paged_result, 0, 0, 2)
ZEND_ARG_INFO(0, link)
ZEND_ARG_INFO(0, pagesize)
ZEND_ARG_INFO(0, iscritical)
ZEND_ARG_INFO(0, cookie)
ZEND_END_ARG_INFO();
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_ctrl_paged_results_resp, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_control_paged_result_response, 0, 0, 2)
ZEND_ARG_INFO(0, link)
ZEND_ARG_INFO(0, result)
ZEND_ARG_INFO(1, cookie)
@@ -2709,8 +2710,8 @@
#endif
#ifdef LDAP_CONTROL_PAGEDRESULTS
- PHP_FE(ldap_ctrl_paged_results, arginfo_ldap_ctrl_paged_results)
- PHP_FE(ldap_ctrl_paged_results_resp, arginfo_ldap_ctrl_paged_results_resp)
+ PHP_FE(ldap_control_paged_result, arginfo_ldap_control_paged_result)
+ PHP_FE(ldap_control_paged_result_response, arginfo_ldap_control_paged_result_response)
#endif
{NULL, NULL, NULL}
};
Added: php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation1.phpt
===================================================================
--- php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation1.phpt (rev 0)
+++ php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation1.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -0,0 +1,56 @@
+--TEST--
+ldap_ldap_control_paged_results() test (fetching the first page)
+--CREDITS--
+Jean-Sebastien Hedde <[email protected]>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifbindfailure.inc');
+?>
+--FILE--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link);
+
+$dn = "dc=my-domain,dc=com";
+$filter = "(cn=*)";
+var_dump(
+ ldap_control_paged_results($link, 1),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result)
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+remove_dummy_data($link);
+?>
+--EXPECTF--
+bool(true)
+resource(6) of type (ldap result)
+array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userA"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userA,dc=my-domain,dc=com"
+ }
+}
+===DONE===
Added: php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation2.phpt
===================================================================
--- php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation2.phpt (rev 0)
+++ php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation2.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -0,0 +1,72 @@
+--TEST--
+ldap_ldap_control_paged_results() test (fetching the first page with a pagesize=2)
+--CREDITS--
+Jean-Sebastien Hedde <[email protected]>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifbindfailure.inc');
+?>
+--FILE--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link);
+
+$dn = "dc=my-domain,dc=com";
+$filter = "(cn=*)";
+var_dump(
+ ldap_control_paged_results($link, 2),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result)
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+remove_dummy_data($link);
+?>
+--EXPECTF--
+bool(true)
+resource(6) of type (ldap result)
+array(3) {
+ ["count"]=>
+ int(2)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userA"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userA,dc=my-domain,dc=com"
+ }
+ [1]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userB"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userB,dc=my-domain,dc=com"
+ }
+}
+===DONE===
Added: php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation3.phpt
===================================================================
--- php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation3.phpt (rev 0)
+++ php/php-src/trunk/ext/ldap/tests/ldap_control_paged_results_variation3.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -0,0 +1,100 @@
+--TEST--
+ldap_ldap_control_paged_results() test (fetching the first page then the next final page)
+--CREDITS--
+Jean-Sebastien Hedde <[email protected]>
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifbindfailure.inc');
+?>
+--FILE--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link);
+
+$dn = "dc=my-domain,dc=com";
+$filter = "(cn=*)";
+$cookie = '';
+var_dump(
+ ldap_control_paged_results($link, 2, true, $cookie),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result),
+ ldap_control_paged_results_response($link, $result, $cookie),
+ ldap_control_paged_results($link, 20, true, $cookie),
+ $result = ldap_search($link, $dn, $filter, array('cn')),
+ ldap_get_entries($link, $result)
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+remove_dummy_data($link);
+?>
+--EXPECTF--
+bool(true)
+resource(%d) of type (ldap result)
+array(3) {
+ ["count"]=>
+ int(2)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userA"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userA,dc=my-domain,dc=com"
+ }
+ [1]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userB"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(28) "cn=userB,dc=my-domain,dc=com"
+ }
+}
+bool(true)
+bool(true)
+resource(%d) of type (ldap result)
+array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ array(4) {
+ ["cn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(5) "userC"
+ }
+ [0]=>
+ string(2) "cn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
+ }
+}
+===DONE===
Deleted: php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt
===================================================================
--- php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation1.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -1,56 +0,0 @@
---TEST--
-ldap_ldap_ctrl_paged_results() test (fetching the first page)
---CREDITS--
-Jean-Sebastien Hedde <[email protected]>
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifbindfailure.inc');
-?>
---FILE--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-insert_dummy_data($link);
-
-$dn = "dc=my-domain,dc=com";
-$filter = "(cn=*)";
-var_dump(
- ldap_ctrl_paged_results($link, 1),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result)
-);
-?>
-===DONE===
---CLEAN--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-remove_dummy_data($link);
-?>
---EXPECTF--
-bool(true)
-resource(6) of type (ldap result)
-array(2) {
- ["count"]=>
- int(1)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userA"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userA,dc=my-domain,dc=com"
- }
-}
-===DONE===
Deleted: php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt
===================================================================
--- php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation2.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -1,72 +0,0 @@
---TEST--
-ldap_ldap_ctrl_paged_results() test (fetching the first page with a pagesize=2)
---CREDITS--
-Jean-Sebastien Hedde <[email protected]>
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifbindfailure.inc');
-?>
---FILE--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-insert_dummy_data($link);
-
-$dn = "dc=my-domain,dc=com";
-$filter = "(cn=*)";
-var_dump(
- ldap_ctrl_paged_results($link, 2),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result)
-);
-?>
-===DONE===
---CLEAN--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-remove_dummy_data($link);
-?>
---EXPECTF--
-bool(true)
-resource(6) of type (ldap result)
-array(3) {
- ["count"]=>
- int(2)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userA"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userA,dc=my-domain,dc=com"
- }
- [1]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userB"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userB,dc=my-domain,dc=com"
- }
-}
-===DONE===
Deleted: php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt
===================================================================
--- php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt 2011-05-19 17:38:03 UTC (rev 311263)
+++ php/php-src/trunk/ext/ldap/tests/ldap_ctrl_paged_results_variation3.phpt 2011-05-19 17:41:21 UTC (rev 311264)
@@ -1,100 +0,0 @@
---TEST--
-ldap_ldap_ctrl_paged_results() test (fetching the first page then the next final page)
---CREDITS--
-Jean-Sebastien Hedde <[email protected]>
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifbindfailure.inc');
-?>
---FILE--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-insert_dummy_data($link);
-
-$dn = "dc=my-domain,dc=com";
-$filter = "(cn=*)";
-$cookie = '';
-var_dump(
- ldap_ctrl_paged_results($link, 2, true, $cookie),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result),
- ldap_ctrl_paged_results_resp($link, $result, $cookie),
- ldap_ctrl_paged_results($link, 20, true, $cookie),
- $result = ldap_search($link, $dn, $filter, array('cn')),
- ldap_get_entries($link, $result)
-);
-?>
-===DONE===
---CLEAN--
-<?php
-include "connect.inc";
-
-$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
-remove_dummy_data($link);
-?>
---EXPECTF--
-bool(true)
-resource(%d) of type (ldap result)
-array(3) {
- ["count"]=>
- int(2)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userA"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userA,dc=my-domain,dc=com"
- }
- [1]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userB"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(28) "cn=userB,dc=my-domain,dc=com"
- }
-}
-bool(true)
-bool(true)
-resource(%d) of type (ldap result)
-array(2) {
- ["count"]=>
- int(1)
- [0]=>
- array(4) {
- ["cn"]=>
- array(2) {
- ["count"]=>
- int(1)
- [0]=>
- string(5) "userC"
- }
- [0]=>
- string(2) "cn"
- ["count"]=>
- int(1)
- ["dn"]=>
- string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
- }
-}
-===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php