Skip to content

Remove deprecated ldap_control_paged_result(_response) #6235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ PHP 8.0 UPGRADE NOTES
constants have been added.

- LDAP:
. The deprecated function ldap_sort has been removed.
. The deprecated functions ldap_sort(), ldap_control_paged_result() and
ldap_control_paged_result_response() have been removed.
. The interface of ldap_set_rebind_proc has changed; the $callback parameter
does not accept empty string anymore; null value shall be used instead.

Expand Down
189 changes: 0 additions & 189 deletions ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3879,195 +3879,6 @@ PHP_FUNCTION(ldap_8859_to_t61)
/* }}} */
#endif

#ifdef LDAP_CONTROL_PAGEDRESULTS
/* {{{ Inject paged results control*/
PHP_FUNCTION(ldap_control_paged_result)
{
zend_long pagesize;
zend_bool iscritical;
zval *link;
char *cookie = NULL;
size_t cookie_len = 0;
struct berval lcookie = { 0L, NULL };
ldap_linkdata *ld;
LDAP *ldap;
BerElement *ber = NULL;
LDAPControl ctrl, *ctrlsp[2];
int rc, myargcount = ZEND_NUM_ARGS();

if (zend_parse_parameters(myargcount, "rl|bs", &link, &pagesize, &iscritical, &cookie, &cookie_len) != SUCCESS) {
RETURN_THROWS();
}

if (Z_TYPE_P(link) == IS_NULL) {
ldap = NULL;
} else {
if ((ld = (ldap_linkdata *)zend_fetch_resource_ex(link, "ldap link", le_link)) == NULL) {
RETURN_THROWS();
}
ldap = ld->link;
}

ber = ber_alloc_t(LBER_USE_DER);
if (ber == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to alloc BER encoding resources for paged results control");
RETURN_FALSE;
}

ctrl.ldctl_iscritical = 0;

switch (myargcount) {
case 4:
lcookie.bv_val = cookie;
lcookie.bv_len = cookie_len;
/* fallthru */
case 3:
ctrl.ldctl_iscritical = (int)iscritical;
/* fallthru */
}

if (ber_printf(ber, "{iO}", (int)pagesize, &lcookie) == LBER_ERROR) {
php_error_docref(NULL, E_WARNING, "Unable to BER printf paged results control");
RETVAL_FALSE;
goto lcpr_error_out;
}
rc = ber_flatten2(ber, &ctrl.ldctl_value, 0);
if (rc == LBER_ERROR) {
php_error_docref(NULL, E_WARNING, "Unable to BER encode paged results control");
RETVAL_FALSE;
goto lcpr_error_out;
}

ctrl.ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;

if (ldap) {
/* directly set the option */
ctrlsp[0] = &ctrl;
ctrlsp[1] = NULL;

rc = ldap_set_option(ldap, LDAP_OPT_SERVER_CONTROLS, ctrlsp);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Unable to set paged results control: %s (%d)", ldap_err2string(rc), rc);
RETVAL_FALSE;
goto lcpr_error_out;
}
RETVAL_TRUE;
} else {
/* return a PHP control object */
array_init(return_value);

add_assoc_string(return_value, "oid", ctrl.ldctl_oid);
if (ctrl.ldctl_value.bv_len) {
add_assoc_stringl(return_value, "value", ctrl.ldctl_value.bv_val, ctrl.ldctl_value.bv_len);
}
if (ctrl.ldctl_iscritical) {
add_assoc_bool(return_value, "iscritical", ctrl.ldctl_iscritical);
}
}

lcpr_error_out:
if (ber != NULL) {
ber_free(ber, 1);
}
return;
}
/* }}} */

/* {{{ Extract paged results control response */
PHP_FUNCTION(ldap_control_paged_result_response)
{
zval *link, *result, *cookie, *estimated;
struct berval lcookie;
int lestimated;
ldap_linkdata *ld;
LDAPMessage *ldap_result;
LDAPControl **lserverctrls, *lctrl;
BerElement *ber;
ber_tag_t tag;
int rc, lerrcode, myargcount = ZEND_NUM_ARGS();

if (zend_parse_parameters(myargcount, "rr|zz", &link, &result, &cookie, &estimated) != SUCCESS) {
RETURN_THROWS();
}

if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
RETURN_THROWS();
}

if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
RETURN_THROWS();
}

rc = ldap_parse_result(ld->link,
ldap_result,
&lerrcode,
NULL, /* matcheddn */
NULL, /* errmsg */
NULL, /* referrals */
&lserverctrls,
0);

if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Unable to parse result: %s (%d)", ldap_err2string(rc), rc);
RETURN_FALSE;
}

if (lerrcode != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Result is: %s (%d)", ldap_err2string(lerrcode), lerrcode);
RETURN_FALSE;
}

if (lserverctrls == NULL) {
php_error_docref(NULL, E_WARNING, "No server controls in result");
RETURN_FALSE;
}

lctrl = ldap_control_find(LDAP_CONTROL_PAGEDRESULTS, lserverctrls, NULL);
if (lctrl == NULL) {
ldap_controls_free(lserverctrls);
php_error_docref(NULL, E_WARNING, "No paged results control response in result");
RETURN_FALSE;
}

ber = ber_init(&lctrl->ldctl_value);
if (ber == NULL) {
ldap_controls_free(lserverctrls);
php_error_docref(NULL, E_WARNING, "Unable to alloc BER decoding resources for paged results control response");
RETURN_FALSE;
}

tag = ber_scanf(ber, "{io}", &lestimated, &lcookie);
(void)ber_free(ber, 1);

if (tag == LBER_ERROR) {
ldap_controls_free(lserverctrls);
php_error_docref(NULL, E_WARNING, "Unable to decode paged results control response");
RETURN_FALSE;
}

if (lestimated < 0) {
ldap_controls_free(lserverctrls);
php_error_docref(NULL, E_WARNING, "Invalid paged results control response value");
RETURN_FALSE;
}

ldap_controls_free(lserverctrls);
if (myargcount == 4) {
ZEND_TRY_ASSIGN_REF_LONG(estimated, lestimated);
}

if (lcookie.bv_len == 0) {
ZEND_TRY_ASSIGN_REF_EMPTY_STRING(cookie);
} else {
ZEND_TRY_ASSIGN_REF_STRINGL(cookie, lcookie.bv_val, lcookie.bv_len);
}
ldap_memfree(lcookie.bv_val);

RETURN_TRUE;
}
/* }}} */
#endif

/* {{{ Extended operations, Pierangelo Masarati */
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
/* {{{ Extended operation */
Expand Down
18 changes: 0 additions & 18 deletions ext/ldap/ldap.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,6 @@ function ldap_err2str(int $errno): string {}
/** @param resource $ldap */
function ldap_compare($ldap, string $dn, string $attribute, string $value, array $controls = []): bool|int {}


#ifdef LDAP_CONTROL_PAGEDRESULTS
/**
* @param resource $ldap
* @deprecated since 7.4
*/
function ldap_control_paged_result($ldap, int $pagesize, bool $iscritical = false, string $cookie = ""): bool {}

/**
* @param resource $ldap
* @param resource $result
* @param string $cookie
* @param int $estimated
* @deprecated since 7.4
*/
function ldap_control_paged_result_response($ldap, $result, &$cookie = null, &$estimated = null): bool {}
#endif

#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
/** @param resource $ldap */
function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, array $controls = []): bool {}
Expand Down
32 changes: 1 addition & 31 deletions ext/ldap/ldap_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 0c721a3272fef9d1a06a8cb4163eeb219661fb00 */
* Stub hash: 42f7118d8380424cd4178759cae6cb47b6d9b44f */

#if defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
Expand Down Expand Up @@ -183,24 +183,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_compare, 0, 4, MAY_BE_BOOL|
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()

#if defined(LDAP_CONTROL_PAGEDRESULTS)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_control_paged_result, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, ldap)
ZEND_ARG_TYPE_INFO(0, pagesize, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, iscritical, _IS_BOOL, 0, "false")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cookie, IS_STRING, 0, "\"\"")
ZEND_END_ARG_INFO()
#endif

#if defined(LDAP_CONTROL_PAGEDRESULTS)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_control_paged_result_response, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, ldap)
ZEND_ARG_INFO(0, result)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, cookie, "null")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, estimated, "null")
ZEND_END_ARG_INFO()
#endif

#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_rename, 0, 5, _IS_BOOL, 0)
ZEND_ARG_INFO(0, ldap)
Expand Down Expand Up @@ -396,12 +378,6 @@ ZEND_FUNCTION(ldap_errno);
ZEND_FUNCTION(ldap_error);
ZEND_FUNCTION(ldap_err2str);
ZEND_FUNCTION(ldap_compare);
#if defined(LDAP_CONTROL_PAGEDRESULTS)
ZEND_FUNCTION(ldap_control_paged_result);
#endif
#if defined(LDAP_CONTROL_PAGEDRESULTS)
ZEND_FUNCTION(ldap_control_paged_result_response);
#endif
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
ZEND_FUNCTION(ldap_rename);
#endif
Expand Down Expand Up @@ -505,12 +481,6 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(ldap_error, arginfo_ldap_error)
ZEND_FE(ldap_err2str, arginfo_ldap_err2str)
ZEND_FE(ldap_compare, arginfo_ldap_compare)
#if defined(LDAP_CONTROL_PAGEDRESULTS)
ZEND_DEP_FE(ldap_control_paged_result, arginfo_ldap_control_paged_result)
#endif
#if defined(LDAP_CONTROL_PAGEDRESULTS)
ZEND_DEP_FE(ldap_control_paged_result_response, arginfo_ldap_control_paged_result_response)
#endif
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
ZEND_FE(ldap_rename, arginfo_ldap_rename)
#endif
Expand Down
55 changes: 0 additions & 55 deletions ext/ldap/tests/ldap_control_paged_results_variation1.phpt

This file was deleted.

Loading