Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[LDAP] fix pagination for PHP 7.4 & 8.0#38875

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Nek- wants to merge1 commit intosymfony:4.4fromNek-:fix/ldap-issue-on-php-74-80

Conversation

@Nek-
Copy link
Contributor

@Nek-Nek- commentedOct 28, 2020
edited by nicolas-grekas
Loading

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets#38874
LicenseMIT
Doc PRN/A

After PR#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#38874

@Nek-Nek-force-pushed thefix/ldap-issue-on-php-74-80 branch fromec99d01 to2e8f4ffCompareOctober 29, 2020 00:15
@Nek-Nek- changed the base branch from5.x to4.4October 29, 2020 00:23
@Nek-Nek-force-pushed thefix/ldap-issue-on-php-74-80 branch from2e8f4ff to02f4ffdCompareOctober 29, 2020 08:48
@nicolas-grekasnicolas-grekas changed the title[LDAP] issue #38874 : pagination for PHP 7.4 & 8.0[LDAP] fix pagination for PHP 7.4 & 8.0Oct 29, 2020
@nicolas-grekasnicolas-grekas added this to the4.4 milestoneOct 29, 2020
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

can't this be tested?

$this->serverctrls = [];

if (\PHP_VERSION_ID <70300) {
ldap_control_paged_result_response($con,$result,$cookie);

Choose a reason for hiding this comment

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

What's the point of calling this function when $result === null? Is that legal for its API?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Hum. Not sure. It will probably return an empty string. I have to admit that I never paginated LDAP result so IDK. At least I should send 0 to keep compatibility.

$con =$this->connection->getResource();
$this->controlPagedResultResponse($con,0,'');
$this->serverctrls = [];
$this->controlPagedResultResponse($con,null,'');

Choose a reason for hiding this comment

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

shouldn't we skip calling this method instead here (and keep$this->serverctrls = [];?)
see my other comment

Copy link
ContributorAuthor

@Nek-Nek-Oct 29, 2020
edited
Loading

Choose a reason for hiding this comment

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

I think so. I just wanted to not break anything since I can't test it. It was actually used here in the same context before the refactoring of#38392

See:https://github.com/symfony/symfony/pull/38392/files#diff-24b79f3ac1a99938f5acb158a450e38d30c1984a5d333b5b20f2c38a73d10e31L183

After PRsymfony#38392 there is a little issue in the Symfony code base thatoccurs only for PHP 7.4 and PHP 8.0.This is related to issuesymfony#38874
@Nek-Nek-force-pushed thefix/ldap-issue-on-php-74-80 branch from02f4ffd to65c1166CompareOctober 29, 2020 17:19
return$cookie;
}

if (0 ===$result) {

Choose a reason for hiding this comment

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

to really be compatible and seamless, this should be anelseif - otherwise, we're affecting the behavior on php <=7.3.

a test case would really help if you can have a look

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

There's a return in the previous if content, how can this impact the previous statements? 🤔

I was not able to run the test entire test suite on my computer :( . I'll give another try, but if you have any insights about running slapd that'd be great ^^' .

privatefunctionresetPagination()
{
$con =$this->connection->getResource();
$this->controlPagedResultResponse($con,0,'');
Copy link
Member

@jderussejderusseOct 30, 2020
edited
Loading

Choose a reason for hiding this comment

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

Looking at the original PR :https://github.com/symfony/symfony/pull/38392/files#diff-24b79f3ac1a99938f5acb158a450e38d30c1984a5d333b5b20f2c38a73d10e31L183-R177

I think the fix, should be to change this line to:

Suggested change
$this->controlPagedResultResponse($con,0,'');
$this->controlPagedResult($con,0,'');

and keep the rest of the code.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

@lucasabalucasabaOct 30, 2020
edited
Loading

Choose a reason for hiding this comment

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

Not sure. The original error is on#38874 isWarning: ldap_parse_result() expects parameter 2 to be resource, int given.

The only place whereldap_parse_result receive an in is when it is called from
$this->controlPagedResultResponse($con, 0, '');

I think the correct solutions is to call it with$this->controlPagedResultResponse($con, null, '');

But your proposal should work as well... I need to test it. I'll check with a working LDAP env.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lucasaba I think error on#38874 is a result of mistake on#38392
Whyldap_control_paged_result was replaced bycontrolPagedResultResponse, notcontrolPagedResult?

Copy link
Member

Choose a reason for hiding this comment

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

my point is, when. you replacedldap_parse_result() bycontrolPagedResult in#38392, in that line you replaced it bycontrolPagedResultResponse.

This explain why the second argument is0 and not a ressources.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've created a new repository with a test openldap server with the configuration needed by symony's tests.
You can find it here:https://github.com/lucasaba/symfony-ldap-test-server

Justdocker-compose up it and launch test suite.

@jderusse suggestion fixes the problem. But I need some more time to make other checks. I'm unable to delete entries and I'm not sure if the problem is the LDAP server or the code.

Copy link
Contributor

@lucasabalucasabaOct 31, 2020
edited
Loading

Choose a reason for hiding this comment

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

By the way: I had to modify AdapterTest and remove

constPAGINATION_REQUIRED_CONFIG = ['options' => ['protocol_version' =>3,        ],    ];

And I had to add, in LdapTestCase, afterldap_connect, the following:

ldap_set_option($h,LDAP_OPT_PROTOCOL_VERSION,3);

Copy link
Contributor

Choose a reason for hiding this comment

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

@jderusse You're completly right! Its all my bad.
@Nek- I could launch locally the tests and they all pass. I should've done it earlier. I'm not able to add the ldap server on github actions because I still don't have enough knowledge.

To launch the tests, just clonehttps://github.com/lucasaba/symfony-ldap-test-server, build it and launch it. Then you can run phpunit against the LDAP tests.

Just some more notes (since you're working on it):

  • remove definition of thePAGINATION_REQUIRED_CONFIG constant fromsrc/Symfony/Component/Ldap/Tests/Adapter/ExtLdap.php and all its reference from the same file (it doesn't work)
  • addldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3); onsrc/Symfony/Component/Ldap/Tests/LdapTestCase.php just after the connection
  • at row 85, insrc/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php, modify the test. The exception is aLdapException.AlreadyExistsException is used for an already existing connection.
  • after thetestLdapAddDouble there is a new entry ('cn=Elsa Amrouche,dc=symfony,dc=com'). This will break all successive tests.... you should find a way to remove the entry just after the test....
  • at row 213, insrc/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php substitute the line with:
// $newEntry->getAttribute('cn') returns an array not a string$this->assertContains($originalCN,$newEntry->getAttribute('cn'));$this->assertContains('Kevin',$newEntry->getAttribute('cn'));

Copy link
ContributorAuthor

@Nek-Nek-Nov 1, 2020
edited
Loading

Choose a reason for hiding this comment

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

Idk if it's related to be being under WSL ^^' but even with the docker it's not working (even with rebinding ports).

Since I can't run the whole test suite I think cleaning the test suite is not a super good idea since it's out of the scope of this PR.

lucasaba reacted with thumbs up emoji
@jderussejderusse mentioned this pull requestNov 7, 2020
@fabpot
Copy link
Member

Closing in favor of#39031

@fabpotfabpot closed thisNov 9, 2020
fabpot added a commit that referenced this pull requestNov 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/AThis replaces#38875 to fix a bug introduced by#38392Commits-------4fe0a6f Fix LDAP pagination
derrabus added a commit that referenced this pull requestNov 16, 2020
This PR was merged into the 4.4 branch.Discussion----------[LDAP] Add ldap tests to github CI| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#39028| License       | MIT| Doc PR        |Adds LDAP test on github actions pipeline and corrects sum bugs in the LDAP Component testIt also adds a bug resolution from@Nek- made in#38875Commits-------ea78f72 Use GithubAction to run ldap testsaf9562b Adds LDAP Adapter test in integration group
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@jderussejderussejderusse left review comments

+2 more reviewers

@lucasabalucasabalucasaba left review comments

@a-menshchikova-menshchikova-menshchikov left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

7 participants

@Nek-@fabpot@lucasaba@nicolas-grekas@jderusse@a-menshchikov@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp