Skip to content
forked from php/php-src

Commit 550a4f2

Browse files
author
Côme Chilliet
committed
Remove deprecated functions from php-ldap
Remove ldap_control_paged_result and ldap_control_paged_result_response which have been deprecated in PHP 7.4, in favor of new $controls parameters for ldap request functions.
1 parent 9fbffe4 commit 550a4f2

8 files changed

+5
-471
lines changed

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ PHP 8.0 UPGRADE NOTES
341341

342342
- LDAP:
343343
. The deprecated function ldap_sort has been removed.
344+
. The deprecated function ldap_control_paged_result has been removed.
345+
. The deprecated function ldap_control_paged_result_response has been removed.
344346
. The interface of ldap_set_rebind_proc has changed; the $callback parameter
345347
does not accept empty string anymore; null value shall be used instead.
346348

ext/ldap/ldap.c

Lines changed: 0 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,195 +3879,6 @@ PHP_FUNCTION(ldap_8859_to_t61)
38793879
/* }}} */
38803880
#endif
38813881

3882-
#ifdef LDAP_CONTROL_PAGEDRESULTS
3883-
/* {{{ Inject paged results control*/
3884-
PHP_FUNCTION(ldap_control_paged_result)
3885-
{
3886-
zend_long pagesize;
3887-
zend_bool iscritical;
3888-
zval *link;
3889-
char *cookie = NULL;
3890-
size_t cookie_len = 0;
3891-
struct berval lcookie = { 0L, NULL };
3892-
ldap_linkdata *ld;
3893-
LDAP *ldap;
3894-
BerElement *ber = NULL;
3895-
LDAPControl ctrl, *ctrlsp[2];
3896-
int rc, myargcount = ZEND_NUM_ARGS();
3897-
3898-
if (zend_parse_parameters(myargcount, "rl|bs", &link, &pagesize, &iscritical, &cookie, &cookie_len) != SUCCESS) {
3899-
RETURN_THROWS();
3900-
}
3901-
3902-
if (Z_TYPE_P(link) == IS_NULL) {
3903-
ldap = NULL;
3904-
} else {
3905-
if ((ld = (ldap_linkdata *)zend_fetch_resource_ex(link, "ldap link", le_link)) == NULL) {
3906-
RETURN_THROWS();
3907-
}
3908-
ldap = ld->link;
3909-
}
3910-
3911-
ber = ber_alloc_t(LBER_USE_DER);
3912-
if (ber == NULL) {
3913-
php_error_docref(NULL, E_WARNING, "Unable to alloc BER encoding resources for paged results control");
3914-
RETURN_FALSE;
3915-
}
3916-
3917-
ctrl.ldctl_iscritical = 0;
3918-
3919-
switch (myargcount) {
3920-
case 4:
3921-
lcookie.bv_val = cookie;
3922-
lcookie.bv_len = cookie_len;
3923-
/* fallthru */
3924-
case 3:
3925-
ctrl.ldctl_iscritical = (int)iscritical;
3926-
/* fallthru */
3927-
}
3928-
3929-
if (ber_printf(ber, "{iO}", (int)pagesize, &lcookie) == LBER_ERROR) {
3930-
php_error_docref(NULL, E_WARNING, "Unable to BER printf paged results control");
3931-
RETVAL_FALSE;
3932-
goto lcpr_error_out;
3933-
}
3934-
rc = ber_flatten2(ber, &ctrl.ldctl_value, 0);
3935-
if (rc == LBER_ERROR) {
3936-
php_error_docref(NULL, E_WARNING, "Unable to BER encode paged results control");
3937-
RETVAL_FALSE;
3938-
goto lcpr_error_out;
3939-
}
3940-
3941-
ctrl.ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;
3942-
3943-
if (ldap) {
3944-
/* directly set the option */
3945-
ctrlsp[0] = &ctrl;
3946-
ctrlsp[1] = NULL;
3947-
3948-
rc = ldap_set_option(ldap, LDAP_OPT_SERVER_CONTROLS, ctrlsp);
3949-
if (rc != LDAP_SUCCESS) {
3950-
php_error_docref(NULL, E_WARNING, "Unable to set paged results control: %s (%d)", ldap_err2string(rc), rc);
3951-
RETVAL_FALSE;
3952-
goto lcpr_error_out;
3953-
}
3954-
RETVAL_TRUE;
3955-
} else {
3956-
/* return a PHP control object */
3957-
array_init(return_value);
3958-
3959-
add_assoc_string(return_value, "oid", ctrl.ldctl_oid);
3960-
if (ctrl.ldctl_value.bv_len) {
3961-
add_assoc_stringl(return_value, "value", ctrl.ldctl_value.bv_val, ctrl.ldctl_value.bv_len);
3962-
}
3963-
if (ctrl.ldctl_iscritical) {
3964-
add_assoc_bool(return_value, "iscritical", ctrl.ldctl_iscritical);
3965-
}
3966-
}
3967-
3968-
lcpr_error_out:
3969-
if (ber != NULL) {
3970-
ber_free(ber, 1);
3971-
}
3972-
return;
3973-
}
3974-
/* }}} */
3975-
3976-
/* {{{ Extract paged results control response */
3977-
PHP_FUNCTION(ldap_control_paged_result_response)
3978-
{
3979-
zval *link, *result, *cookie, *estimated;
3980-
struct berval lcookie;
3981-
int lestimated;
3982-
ldap_linkdata *ld;
3983-
LDAPMessage *ldap_result;
3984-
LDAPControl **lserverctrls, *lctrl;
3985-
BerElement *ber;
3986-
ber_tag_t tag;
3987-
int rc, lerrcode, myargcount = ZEND_NUM_ARGS();
3988-
3989-
if (zend_parse_parameters(myargcount, "rr|zz", &link, &result, &cookie, &estimated) != SUCCESS) {
3990-
RETURN_THROWS();
3991-
}
3992-
3993-
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
3994-
RETURN_THROWS();
3995-
}
3996-
3997-
if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
3998-
RETURN_THROWS();
3999-
}
4000-
4001-
rc = ldap_parse_result(ld->link,
4002-
ldap_result,
4003-
&lerrcode,
4004-
NULL, /* matcheddn */
4005-
NULL, /* errmsg */
4006-
NULL, /* referrals */
4007-
&lserverctrls,
4008-
0);
4009-
4010-
if (rc != LDAP_SUCCESS) {
4011-
php_error_docref(NULL, E_WARNING, "Unable to parse result: %s (%d)", ldap_err2string(rc), rc);
4012-
RETURN_FALSE;
4013-
}
4014-
4015-
if (lerrcode != LDAP_SUCCESS) {
4016-
php_error_docref(NULL, E_WARNING, "Result is: %s (%d)", ldap_err2string(lerrcode), lerrcode);
4017-
RETURN_FALSE;
4018-
}
4019-
4020-
if (lserverctrls == NULL) {
4021-
php_error_docref(NULL, E_WARNING, "No server controls in result");
4022-
RETURN_FALSE;
4023-
}
4024-
4025-
lctrl = ldap_control_find(LDAP_CONTROL_PAGEDRESULTS, lserverctrls, NULL);
4026-
if (lctrl == NULL) {
4027-
ldap_controls_free(lserverctrls);
4028-
php_error_docref(NULL, E_WARNING, "No paged results control response in result");
4029-
RETURN_FALSE;
4030-
}
4031-
4032-
ber = ber_init(&lctrl->ldctl_value);
4033-
if (ber == NULL) {
4034-
ldap_controls_free(lserverctrls);
4035-
php_error_docref(NULL, E_WARNING, "Unable to alloc BER decoding resources for paged results control response");
4036-
RETURN_FALSE;
4037-
}
4038-
4039-
tag = ber_scanf(ber, "{io}", &lestimated, &lcookie);
4040-
(void)ber_free(ber, 1);
4041-
4042-
if (tag == LBER_ERROR) {
4043-
ldap_controls_free(lserverctrls);
4044-
php_error_docref(NULL, E_WARNING, "Unable to decode paged results control response");
4045-
RETURN_FALSE;
4046-
}
4047-
4048-
if (lestimated < 0) {
4049-
ldap_controls_free(lserverctrls);
4050-
php_error_docref(NULL, E_WARNING, "Invalid paged results control response value");
4051-
RETURN_FALSE;
4052-
}
4053-
4054-
ldap_controls_free(lserverctrls);
4055-
if (myargcount == 4) {
4056-
ZEND_TRY_ASSIGN_REF_LONG(estimated, lestimated);
4057-
}
4058-
4059-
if (lcookie.bv_len == 0) {
4060-
ZEND_TRY_ASSIGN_REF_EMPTY_STRING(cookie);
4061-
} else {
4062-
ZEND_TRY_ASSIGN_REF_STRINGL(cookie, lcookie.bv_val, lcookie.bv_len);
4063-
}
4064-
ldap_memfree(lcookie.bv_val);
4065-
4066-
RETURN_TRUE;
4067-
}
4068-
/* }}} */
4069-
#endif
4070-
40713882
/* {{{ Extended operations, Pierangelo Masarati */
40723883
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
40733884
/* {{{ Extended operation */

ext/ldap/ldap.stub.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,6 @@ function ldap_err2str(int $errno): string {}
187187
/** @param resource $ldap */
188188
function ldap_compare($ldap, string $dn, string $attribute, string $value, array $controls = []): bool|int {}
189189

190-
191-
#ifdef LDAP_CONTROL_PAGEDRESULTS
192-
/**
193-
* @param resource $ldap
194-
* @deprecated since 7.4
195-
*/
196-
function ldap_control_paged_result($ldap, int $pagesize, bool $iscritical = false, string $cookie = ""): bool {}
197-
198-
/**
199-
* @param resource $ldap
200-
* @param resource $result
201-
* @param string $cookie
202-
* @param int $estimated
203-
* @deprecated since 7.4
204-
*/
205-
function ldap_control_paged_result_response($ldap, $result, &$cookie = null, &$estimated = null): bool {}
206-
#endif
207-
208190
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
209191
/** @param resource $ldap */
210192
function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, array $controls = []): bool {}

ext/ldap/ldap_arginfo.h

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 0c721a3272fef9d1a06a8cb4163eeb219661fb00 */
2+
* Stub hash: 42f7118d8380424cd4178759cae6cb47b6d9b44f */
33

44
#if defined(HAVE_ORALDAP)
55
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
@@ -183,24 +183,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_compare, 0, 4, MAY_BE_BOOL|
183183
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 0, "[]")
184184
ZEND_END_ARG_INFO()
185185

186-
#if defined(LDAP_CONTROL_PAGEDRESULTS)
187-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_control_paged_result, 0, 2, _IS_BOOL, 0)
188-
ZEND_ARG_INFO(0, ldap)
189-
ZEND_ARG_TYPE_INFO(0, pagesize, IS_LONG, 0)
190-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, iscritical, _IS_BOOL, 0, "false")
191-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cookie, IS_STRING, 0, "\"\"")
192-
ZEND_END_ARG_INFO()
193-
#endif
194-
195-
#if defined(LDAP_CONTROL_PAGEDRESULTS)
196-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_control_paged_result_response, 0, 2, _IS_BOOL, 0)
197-
ZEND_ARG_INFO(0, ldap)
198-
ZEND_ARG_INFO(0, result)
199-
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, cookie, "null")
200-
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, estimated, "null")
201-
ZEND_END_ARG_INFO()
202-
#endif
203-
204186
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
205187
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_rename, 0, 5, _IS_BOOL, 0)
206188
ZEND_ARG_INFO(0, ldap)
@@ -396,12 +378,6 @@ ZEND_FUNCTION(ldap_errno);
396378
ZEND_FUNCTION(ldap_error);
397379
ZEND_FUNCTION(ldap_err2str);
398380
ZEND_FUNCTION(ldap_compare);
399-
#if defined(LDAP_CONTROL_PAGEDRESULTS)
400-
ZEND_FUNCTION(ldap_control_paged_result);
401-
#endif
402-
#if defined(LDAP_CONTROL_PAGEDRESULTS)
403-
ZEND_FUNCTION(ldap_control_paged_result_response);
404-
#endif
405381
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
406382
ZEND_FUNCTION(ldap_rename);
407383
#endif
@@ -505,12 +481,6 @@ static const zend_function_entry ext_functions[] = {
505481
ZEND_FE(ldap_error, arginfo_ldap_error)
506482
ZEND_FE(ldap_err2str, arginfo_ldap_err2str)
507483
ZEND_FE(ldap_compare, arginfo_ldap_compare)
508-
#if defined(LDAP_CONTROL_PAGEDRESULTS)
509-
ZEND_DEP_FE(ldap_control_paged_result, arginfo_ldap_control_paged_result)
510-
#endif
511-
#if defined(LDAP_CONTROL_PAGEDRESULTS)
512-
ZEND_DEP_FE(ldap_control_paged_result_response, arginfo_ldap_control_paged_result_response)
513-
#endif
514484
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
515485
ZEND_FE(ldap_rename, arginfo_ldap_rename)
516486
#endif

ext/ldap/tests/ldap_control_paged_results_variation1.phpt

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)