Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100056 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53973 invoked from network); 27 Jul 2017 08:22:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jul 2017 08:22:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=come@opensides.be; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=come@opensides.be; sender-id=pass Received-SPF: pass (pb1.pair.com: domain opensides.be designates 195.154.20.141 as permitted sender) X-PHP-List-Original-Sender: come@opensides.be X-Host-Fingerprint: 195.154.20.141 smtp.opensides.be Received: from [195.154.20.141] ([195.154.20.141:49684] helo=smtp.opensides.be) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/13-17354-CB2A9795 for ; Thu, 27 Jul 2017 04:22:21 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.opensides.be (Postfix) with ESMTP id BEF571C2AF8 for ; Thu, 27 Jul 2017 10:22:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at opensides.be Received: from smtp.opensides.be ([127.0.0.1]) by localhost (smtp.opensides.be [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oO0AgNLRa5gx for ; Thu, 27 Jul 2017 10:22:16 +0200 (CEST) Received: from mcmic-probook.localnet (63.120.199.77.rev.sfr.net [77.199.120.63]) by smtp.opensides.be (Postfix) with ESMTPSA id 2CA031C241C for ; Thu, 27 Jul 2017 10:22:16 +0200 (CEST) To: internals@lists.php.net Date: Thu, 27 Jul 2017 10:21:59 +0200 Message-ID: <2222318.RmTdGqdFAJ@mcmic-probook> Organization: OpenSides User-Agent: KMail/5.2.3 (Linux/4.9.0-3-amd64; KDE/5.28.0; x86_64; ; ) In-Reply-To: References: <2177132.cc4GXqHK7k@mcmic-probook> <1695890.Q3ruuQZBqi@mcmic-probook> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2567749.BAnAypktjk" Content-Transfer-Encoding: 7Bit Subject: Re: [PHP-DEV] LDAP controls support API [Question for the RM at the end] From: come@opensides.be (=?ISO-8859-1?Q?C=F4me?= Chilliet) --nextPart2567749.BAnAypktjk Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Le mercredi 26 juillet 2017, 12:48:04 CEST Sara Golemon a =C3=A9crit : > The current return value for 4 or more args is simply `true`, so the > BC break would be trivial to make that a resource (which evaluates as > true), but I think we can make that even simpler. Just fix it before > beta3 (or beta2 if the fix is already ready) and I won't tell on you > to Remi. So how about the patch attached? I did not include your suggested changes as I did not manage to make it wor= k for now, plus this will have to be changed for all functions so I=E2=80= =99d prefer to work on this clean up after I get back from holidays at the = end of August. But thanks for the suggested changes, ext/ldap code does need more set of e= yes looking at it and I do not master PHP internal features yet. C=C3=B4me --nextPart2567749.BAnAypktjk Content-Disposition: attachment; filename="0001-Added-controls-parameters-to-ldap_exop-so-that-contr.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Added-controls-parameters-to-ldap_exop-so-that-contr.patch" From e8de35b801f4bbeb090ee1bd13958cf77b096429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 27 Jul 2017 09:45:37 +0200 Subject: [PATCH] Added controls parameters to ldap_exop so that control support can be added later --- ext/ldap/ldap.c | 19 ++++++++++++------- ext/ldap/tests/ldap_exop.phpt | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 2fd43359a4..009d37ad29 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -3326,10 +3326,11 @@ PHP_FUNCTION(ldap_control_paged_result_response) /* {{{ Extended operations, Pierangelo Masarati */ #ifdef HAVE_LDAP_EXTENDED_OPERATION_S -/* {{{ proto ? ldap_exop(resource link, string reqoid [, string reqdata [, string retdata [, string retoid]]]) +/* {{{ proto resource ldap_exop(resource link, string reqoid [, string reqdata [, array servercontrols [, array clientcontrols [, string &retdata [, string &retoid]]]]]) Extended operation */ PHP_FUNCTION(ldap_exop) { + zval *servercontrols, *clientcontrols; zval *link, *reqoid, *reqdata, *retdata, *retoid; char *lreqoid, *lretoid = NULL; struct berval lreqdata, *lretdata = NULL; @@ -3338,7 +3339,7 @@ PHP_FUNCTION(ldap_exop) int rc, msgid, myargcount = ZEND_NUM_ARGS(); /* int reqoid_len, reqdata_len, retdata_len, retoid_len, retdat_len; */ - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz|zz/z/", &link, &reqoid, &reqdata, &retdata, &retoid) != SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz|zzzz/z/", &link, &reqoid, &reqdata, &servercontrols, &clientcontrols, &retdata, &retoid) != SUCCESS) { WRONG_PARAM_COUNT; } @@ -3347,6 +3348,8 @@ PHP_FUNCTION(ldap_exop) } switch (myargcount) { + case 7: + case 6: case 5: case 4: case 3: @@ -3359,13 +3362,13 @@ PHP_FUNCTION(ldap_exop) lreqoid = Z_STRVAL_P(reqoid); } - if (myargcount > 3) { + if (myargcount > 5) { /* synchronous call */ rc = ldap_extended_operation_s(ld->link, lreqoid, lreqdata.bv_len > 0 ? &lreqdata: NULL, NULL, NULL, - myargcount > 4 ? &lretoid : NULL, + myargcount > 6 ? &lretoid : NULL, &lretdata ); if (rc != LDAP_SUCCESS ) { php_error_docref(NULL, E_WARNING, "Extended operation %s failed: %s (%d)", lreqoid, ldap_err2string(rc), rc); @@ -3374,7 +3377,7 @@ PHP_FUNCTION(ldap_exop) /* Reverse -> fall through */ switch (myargcount) { - case 5: + case 7: zval_dtor(retoid); if (lretoid == NULL) { ZVAL_EMPTY_STRING(retoid); @@ -3382,7 +3385,7 @@ PHP_FUNCTION(ldap_exop) ZVAL_STRING(retoid, lretoid); ldap_memfree(lretoid); } - case 4: + case 6: /* use arg #4 as the data returned by the server */ zval_dtor(retdata); if (lretdata == NULL) { @@ -3835,10 +3838,12 @@ ZEND_END_ARG_INFO() #endif #ifdef HAVE_LDAP_EXTENDED_OPERATION_S -ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_exop, 0, 0, 5) +ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_exop, 0, 0, 2) ZEND_ARG_INFO(0, link) ZEND_ARG_INFO(0, reqoid) ZEND_ARG_INFO(0, reqdata) + ZEND_ARG_INFO(0, servercontrols) + ZEND_ARG_INFO(0, clientcontrols) ZEND_ARG_INFO(1, retdata) ZEND_ARG_INFO(1, retoid) ZEND_END_ARG_INFO() diff --git a/ext/ldap/tests/ldap_exop.phpt b/ext/ldap/tests/ldap_exop.phpt index cb1afbf934..a80372a555 100644 --- a/ext/ldap/tests/ldap_exop.phpt +++ b/ext/ldap/tests/ldap_exop.phpt @@ -36,10 +36,10 @@ function extract_genpw($retdata) $userAPassword = "oops"; -// ldap_exop(resource link, string reqoid [, string reqdata [, string retoid [, string retdata]]]) -// bool ldap_parse_exop(resource link, resource result [, string retoid [, string retdata]]) +// ldap_exop(resource link, string reqoid [, string reqdata [, array servercontrols [, array clientcontrols [, string &retdata [, string &retoid]]]]]) +// bool ldap_parse_exop(resource link, resource result [, string &retdata [, string &retoid]]) var_dump( - ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, $retdata, $retoid), + ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, NULL, $retdata, $retoid), $retdata, $retoid, $r = ldap_exop($link, LDAP_EXOP_WHO_AM_I), -- 2.11.0 --nextPart2567749.BAnAypktjk--