-
Notifications
You must be signed in to change notification settings - Fork 7.8k
ext/ldap parameter fixes #6153
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
ext/ldap parameter fixes #6153
Conversation
For mech, realm, authcid, authzid and props NULL means do not change current server setting.
…tribute It has been unused and deprecated since PHP 5.2.4
Renamed all parameters to be consistent and concise
Co-authored-by: Nikita Popov <[email protected]>
ext/ldap/ldap.stub.php
Outdated
@@ -4,177 +4,177 @@ | |||
|
|||
#ifdef HAVE_ORALDAP | |||
/** @return resource|false */ | |||
function ldap_connect(string $hostname = UNKNOWN, int $port = 389, string $wallet = UNKNOWN, string $wallet_passwd = UNKNOWN, int $authmode = GSLC_SSL_NO_AUTH) {} | |||
function ldap_connect(string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $wallet_passwd = UNKNOWN, int $authmode = GSLC_SSL_NO_AUTH) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function ldap_connect(string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $wallet_passwd = UNKNOWN, int $authmode = GSLC_SSL_NO_AUTH) {} | |
function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $wallet_passwd = UNKNOWN, int $authmode = GSLC_SSL_NO_AUTH) {} |
and elsewhere. These need to be explicitly marked nullable. I thought the script would throw an error for that :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does throw (at least I got such an exception a few weeks ago)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok.
Should I use ?string or string|null ? I think I’ve seen commits changing one for the other which is why I ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I changed a few such types. Now, we exclusively use ?
for nullable types where it is possible, so please use this format.
ext/ldap/ldap.stub.php
Outdated
/** @param resource $link_identifier */ | ||
function ldap_unbind($link_identifier): bool {} | ||
/** @param resource $link */ | ||
function ldap_unbind($link): bool {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Over in #6172 we're changing $mysql_link
to $connection
. It's probably wise to do the same here. I don't know anyone anywhere that calls this thing a "link".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, it was called $link in some functions and $link_identifier in others which is why I changed to use $link everywhere.
I usually call this $ldap, I think I’ve seen $cid for connection id.
I’m not sure $connection is better, it’s way longer for sure (and for me prone to errors since we write "connexion" in french).
Are there other occurencies than mysql?
Can other people give their opinion (especially native english speakers)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @MCMic i'am also in favour of $ldap i think it make more sense in the context of a ldap library
Cheers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mysqli change ended up deciding on $mysql
as the name, so $ldap
would be the one to use here now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple suggestions for the parameter naming, mostly around using _
to separate words.
ext/ldap/ldap.stub.php
Outdated
/** @param resource $link_identifier */ | ||
function ldap_unbind($link_identifier): bool {} | ||
/** @param resource $link */ | ||
function ldap_unbind($link): bool {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mysqli change ended up deciding on $mysql
as the name, so $ldap
would be the one to use here now.
Co-authored-by: Nikita Popov <[email protected]>
Co-authored-by: Nikita Popov <[email protected]>
Co-authored-by: Nikita Popov <[email protected]>
Co-authored-by: Nikita Popov <[email protected]>
Also fixed ldap_set_option places where $newvalue was still used
@nikic Should be good now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @kocsismate can take a look as well. Sorry for the naming bikeshed :)
Co-authored-by: Nikita Popov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few questions/suggestions. And I'm also sorry for the prolonged bikeshed :)
ext/ldap/ldap.stub.php
Outdated
* @return resource|false | ||
*/ | ||
function ldap_read($link_identifier, array|string $base_dn, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {} | ||
function ldap_read($ldap, array|string $base, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $controls = []) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function ldap_read($ldap, array|string $base, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $controls = []) {} | |
function ldap_read($ldap, array|string $base, array|string $filter, array $attributes = [], int $attributes_only = 0, int $size_limit = -1, int $time_limit = -1, int $deref = LDAP_DEREF_NEVER, array $controls = []) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above, @nikic proposed the same, but both openldap and php use sizelimit and timelimit in other places, it’s always have been a whole word.
I can change $attrsonly though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a big problem with diverging from these other names, but I also don't mind if these stay without the _
. So I'm ok.
ext/ldap/ldap.stub.php
Outdated
* @return resource|false | ||
*/ | ||
function ldap_list($link_identifier, array|string $base_dn, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $servercontrols = []) {} | ||
function ldap_list($ldap, array|string $base, array|string $filter, array $attributes = [], int $attrsonly = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, array $controls = []) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here (and one more below)
* @deprecated since 7.4 | ||
*/ | ||
function ldap_control_paged_result($link, int $pagesize, bool $iscritical = false, string $cookie = ""): bool {} | ||
function ldap_control_paged_result($ldap, int $pagesize, bool $iscritical = false, string $cookie = ""): bool {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function ldap_control_paged_result($ldap, int $pagesize, bool $iscritical = false, string $cookie = ""): bool {} | |
function ldap_control_paged_result($ldap, int $page_size, bool $critical = false, string $cookie = ""): bool {} |
Could just $size
work? Nevertheless, using the page_
prefix is perfectly fine for me.
$is_critical
would be ok for me as well, but I think there's an agreement that we don't use the is_
prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this function is deprecated since PHP-7.4. Can it be removed in PHP-8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be fine to drop. It looks like another deprecated function (ldap_sort) did get dropped already. I'd suggest landing that separately from this PR (just directly commit it with a note in UPGRADING).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we should land this today to ensure the removal goes into PHP 8.0, I've put up #6235. Does that look reasonable?
(Feel free to land your own version though, I just want to make sure it goes in...)
ext/ldap/ldap.stub.php
Outdated
* @param array|string|int $retval | ||
*/ | ||
function ldap_get_option($link_identifier, int $option, &$retval = null): bool {} | ||
function ldap_get_option($ldap, int $option, &$retval = null): bool {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function ldap_get_option($ldap, int $option, &$retval = null): bool {} | |
function ldap_get_option($ldap, int $option, &$return_value = null): bool {} |
or just $value
? the manual says "This will be set to the option value.", so maybe this name would be ok.
ext/ldap/ldap.stub.php
Outdated
*/ | ||
function ldap_parse_result($link, $result, &$errcode, &$matcheddn = null, &$errmsg = null, &$referrals = null, &$serverctrls = null): bool {} | ||
function ldap_parse_result($ldap, $result, &$errcode, &$matcheddn = null, &$errmsg = null, &$referrals = null, &$controls = null): bool {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function ldap_parse_result($ldap, $result, &$errcode, &$matcheddn = null, &$errmsg = null, &$referrals = null, &$controls = null): bool {} | |
function ldap_parse_result($ldap, $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {} |
$errno
could also be used, but so far $error_code
is what we preferred in another PR.
ext/ldap/ldap.stub.php
Outdated
* @param string $retdata | ||
* @param string $retoid | ||
* @return resource|bool | ||
*/ | ||
function ldap_exop($link, string $reqoid, ?string $reqdata = null, ?array $servercontrols = [], &$retdata = null, &$retoid = null) {} | ||
function ldap_exop($ldap, string $reqoid, ?string $reqdata = null, ?array $controls = [], &$retdata = null, &$retoid = null) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would using a $request_
prefix work well? And $response_data
or something similar?
ext/ldap/ldap.stub.php
Outdated
* @param resource $result | ||
* @param string $retdata | ||
* @param string $retoid | ||
*/ | ||
function ldap_parse_exop($link, $result, &$retdata = null, &$retoid = null): bool {} | ||
function ldap_parse_exop($ldap, $result, &$retdata = null, &$retoid = null): bool {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same questions apply :)
@kocsismate Should be good now, except for the deprecated functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I merged this |
This fixes inconsistencies between code, documentation and stub to better support NULL as an equivalent of not passing a parameter.
It also renames parameters to be consistent and concise.