Skip to content

ldap query minor refactoring #28459

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

Closed
wants to merge 4 commits into from
Closed

ldap query minor refactoring #28459

wants to merge 4 commits into from

Conversation

ronfroy
Copy link
Contributor

@ronfroy ronfroy commented Sep 13, 2018

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

@@ -32,12 +32,12 @@ public function __construct(ConnectionInterface $connection, string $dn, string
'maxItems' => 0,
'sizeLimit' => 0,
'timeout' => 0,
'deref' => static::DEREF_NEVER,
'deref' => QueryInterface::DEREF_NEVER,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break backwards compatibility, as you could use them in a child implementation and overwrite them. @csarrazi do you know if that was intentional?

Copy link
Contributor Author

@ronfroy ronfroy Sep 14, 2018

Choose a reason for hiding this comment

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

This is, but it's a design fix too. Const override is really not a good practice, and const must not be part of the interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a BC break nevertheless. The question is whether this is ever used, but we can't check that. Perhaps on initialization of the object you can do something like this?

public function __construct(...)
{
    if (static::DEREF_NEVER !== QueryInterface::DEREF_NEVER) {
        @trigger_error('...', E_USER_DEPRECATED);
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iltar I can not make it deprecated and fixed it in the same time. But i dont think this is ever used.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can trigger the deprecation, which should cause developers to fix the issue. It'll have to be fixed in 5.0. It's up to the core members to decide whether or not this is an acceptable BC break

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, one of the things I'm unsatisfied with is the fact that the values in QueryInterface are actually extracted from the ext_ldap implementation, which is actually problematic as this means that the implementation leaks into the interface.

This was actually the rationale behind using static:: instead of QueryInterface, as the goal was that other implementations could use other values.

For 5.x, the actual values used in the QueryInterface should instead be defined in the actual implementation instead of the interface, and the interface constants should rather be string values.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm personally not a fan of having constants in an interface, because it spreads to every implementation. Would it be an idea to make a final class with private constructor to limit the constants to 1 class instead?

Copy link
Contributor

@csarrazi csarrazi Sep 17, 2018

Choose a reason for hiding this comment

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

I agree. We should create a LdapOption, which would contain string values for each constant.
The actual value (used by ext_ldap) should be limited to the actual implementation, so should only be present in the query implementation.

@@ -37,7 +38,7 @@ public function __destruct()
$con = $this->connection->getResource();
$this->connection = null;

if (null === $this->search || false === $this->search) {
if (\in_array($this->search, array(null, false), true)) {
Copy link
Member

Choose a reason for hiding this comment

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

please revert this change, it's unrelated and not needed

QueryInterface::SCOPE_SUB => 'ldap_search',
);

if (!\array_key_exists($this->options['scope'], $funcMap)) {
Copy link
Member

Choose a reason for hiding this comment

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

"isset" would do it

@ronfroy
Copy link
Contributor Author

ronfroy commented Sep 17, 2018

@nicolas-grekas reverted

@nicolas-grekas nicolas-grekas added this to the next milestone Sep 18, 2018
@fabpot
Copy link
Member

fabpot commented Oct 10, 2018

As this was "just" a refactoring and because it breaks BC, shall we close?

@csarrazi
Copy link
Contributor

Agreed

@fabpot fabpot closed this Oct 12, 2018
@ronfroy ronfroy deleted the ldap-query-refactoring branch October 12, 2018 14:15
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
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.

7 participants