Skip to content
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

[Ldap] Bypass the use of ldap_control_paged_result on PHP >= 7.3 #38392

Merged
merged 1 commit into from
Oct 7, 2020

Conversation

lucasaba
Copy link
Contributor

@lucasaba lucasaba commented Oct 3, 2020

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #38352
License MIT
Doc PR

As stated on #38352 ldap_control_paged_result and ldap_control_paged_result_response have been deprecated since PHP 7.4 and will be removed on PHP 8.0.

With this fix, Query uses serverctrls to handle LDAP results pagination.

Since serverctrls where introduced in PHP 7.3 and they are the only way to circumvent the usage of ldap_control_paged_result, I've added a new Query class implementation which uses serverctrls to control pagination.

To do so I've also had to update the LDAP Adapter in order to use the new class if PHP version 7.3 or greater are found

@lucasaba
Copy link
Contributor Author

lucasaba commented Oct 4, 2020

Side note: to test the component I've created an OpenLDAP instance on docker using latest osixia/openldap. TO make test working, I had to add ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3); in LdapTestCase.

Even with this configuration, some test fails with message Failed asserting that actual size 2 matches expected size 1.. This happens both in my version and in 4.4 version of Symfony.

It would be a good idea to have a docker environment prepared to test those methods....at least in order to have a common environment.

@lucasaba lucasaba marked this pull request as ready for review October 4, 2020 10:13
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Oct 5, 2020
@nicolas-grekas nicolas-grekas changed the title Bypass the use of ldap_control_paged_result if PHP version is 8.0 o… [Ldap] Bypass the use of ldap_control_paged_result on PHP >= 7.3 Oct 5, 2020
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add types (arguments+return) on methods when possible.

src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php Outdated Show resolved Hide resolved
@nicolas-grekas
Copy link
Member

It would be a good idea to have a docker environment prepared to test those methods....at least in order to have a common environment.

I agree. We run such tests in .github/workflows/tests.yml if you'd like to have a look (could be done in a separate PR).

@nicolas-grekas
Copy link
Member

Thank you @lucasaba.

@nicolas-grekas nicolas-grekas merged commit 45cad64 into symfony:4.4 Oct 7, 2020
@lucasaba
Copy link
Contributor Author

lucasaba commented Oct 7, 2020

Thanks to you all! Has been a pleasure and a precious lesson!
Now I'll see .github/workflows/tests.yml and try to create the LDAP service.

@fabpot fabpot mentioned this pull request Oct 14, 2020
This was referenced Oct 28, 2020
Nek- added a commit to Nek-/symfony that referenced this pull request Oct 28, 2020
After PR symfony#38392 there is a little issue in the Symfony code base that
occurs only for PHP 7.4 and PHP 8.0.

This is related to issue symfony#38874
Nek- added a commit to Nek-/symfony that referenced this pull request Oct 29, 2020
After PR symfony#38392 there is a little issue in the Symfony code base that
occurs only for PHP 7.4 and PHP 8.0.

This is related to issue symfony#38874
Nek- added a commit to Nek-/symfony that referenced this pull request Oct 29, 2020
After PR symfony#38392 there is a little issue in the Symfony code base that
occurs only for PHP 7.4 and PHP 8.0.

This is related to issue symfony#38874
Nek- added a commit to Nek-/symfony that referenced this pull request Oct 29, 2020
After PR symfony#38392 there is a little issue in the Symfony code base that
occurs only for PHP 7.4 and PHP 8.0.

This is related to issue symfony#38874
@lucasaba lucasaba mentioned this pull request Nov 7, 2020
@jderusse jderusse mentioned this pull request Nov 7, 2020
fabpot added a commit that referenced this pull request Nov 9, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[Ldap] Fix pagination

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #38874
| License       | MIT
| Doc PR        | N/A

This replaces #38875 to fix a bug introduced by #38392

Commits
-------

4fe0a6f Fix LDAP pagination
chalasr added a commit that referenced this pull request Nov 16, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

Fix critical extension when reseting paged control

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

The issue has been introduced here in #38392 and prevent performing an operation after fetched a paginated result => ldap throws an `Could not XXX: Critical extension is unavailable`

At this line: https://github.com/symfony/symfony/pull/38392/files#diff-24b79f3ac1a99938f5acb158a450e38d30c1984a5d333b5b20f2c38a73d10e31L183, the previous code called `ldap_control_paged_result($con, 0);` using the default value (`false`) for the `$critical` argument.
The replaced version always use `true`.

This PR restore the previous behavior by using `false` when reseting the pagination.

Commits
-------

a2b7476 Fix critical extension when reseting paged control
@jderusse jderusse mentioned this pull request May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants