-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
ldap query minor refactoring #28459
Conversation
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, |
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.
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?
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.
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.
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.
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);
}
}
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.
@iltar I can not make it deprecated and fixed it in the same time. But i dont think this is ever used.
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.
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
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, 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.
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'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?
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 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)) { |
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.
please revert this change, it's unrelated and not needed
QueryInterface::SCOPE_SUB => 'ldap_search', | ||
); | ||
|
||
if (!\array_key_exists($this->options['scope'], $funcMap)) { |
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.
"isset" would do it
@nicolas-grekas reverted |
As this was "just" a refactoring and because it breaks BC, shall we close? |
Agreed |