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

make ILDAPProviderFactory usable when there is no ldap setup #25326

Merged
merged 1 commit into from
Mar 31, 2021

Conversation

icewind1991
Copy link
Member

Currently there is no nice way to inject an LDAPProvider into a class that has optional ldap support, by adding a dummy ILDAPProviderFactory one can be injected even if no ldap is setup, ILDAPProviderFactory::isAvailable can then be used to determine if ldap is available.

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Jan 25, 2021
@icewind1991 icewind1991 added this to the Nextcloud 21 milestone Jan 25, 2021
Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

Good one. API change should be reflected in critical changes, but I don't expect (and am not aware) that there is any custom implementation out there.

@icewind1991
Copy link
Member Author

I was also considering not having the isAvailable method and instead throwing an exception, that would remove the api break but using exceptions for expected behaviour isn't great.

@blizzz
Copy link
Member

blizzz commented Jan 25, 2021

I was also considering not having the isAvailable method and instead throwing an exception, that would remove the api break but using exceptions for expected behaviour isn't great.

No, I agree with you. That was not ideally implemented, and my memory tricked me into thinking: it's a factory, that would not throw Exceptions unnecessarily. Thanks for taking care!

@icewind1991 icewind1991 force-pushed the ldap-factory-no-ldap branch 2 times, most recently from 0d7d69a to 3d7d7b2 Compare January 26, 2021 18:04
@nextcloud nextcloud deleted a comment from faily-bot bot Jan 26, 2021
This was referenced Jan 27, 2021
@rullzer rullzer modified the milestones: Nextcloud 21, Nextcloud 22 Feb 2, 2021
@rullzer
Copy link
Member

rullzer commented Feb 2, 2021

Master is Nextcloud 22 now.
If this should go into 21 it should be backported.

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991
Copy link
Member Author

Rebased

$factory = new $factoryClass($this);
return new $factoryClass($this);
});
$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
Copy link
Member

Choose a reason for hiding this comment

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

I would not allow this. That leads to a direct exception if LDAP is not enabled. I would only allow the way via the factory.

Copy link
Member Author

Choose a reason for hiding this comment

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

This exists for BC reasons, mirroring the previous behavior when apps tried to query LDAPProvider

Copy link
Member

Choose a reason for hiding this comment

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

Got it. I didn't noticed it because of the diff 🙈

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

See inline.

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

👍

@MorrisJobke
Copy link
Member

Good one. API change should be reflected in critical changes, but I don't expect (and am not aware) that there is any custom implementation out there.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants