Skip to content

make ILDAPProviderFactory usable when there is no ldap setup - #25326

Merged
MorrisJobke merged 1 commit into
masterfrom
ldap-factory-no-ldap
Mar 31, 2021
Merged

make ILDAPProviderFactory usable when there is no ldap setup#25326
MorrisJobke merged 1 commit into
masterfrom
ldap-factory-no-ldap

Conversation

@icewind1991

Copy link
Copy Markdown
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.

@icewind1991icewind1991 added the 3. to review Waiting for reviews label Jan 25, 2021
@icewind1991icewind1991 added this to the Nextcloud 21 milestone Jan 25, 2021

@blizzzblizzz left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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.

@nextcloudnextcloud deleted a comment from faily-botBotJan 25, 2021
@blizzz

Copy link
Copy Markdown
Member

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
icewind1991force-pushed the ldap-factory-no-ldap branch 2 times, most recently from 0d7d69a to 3d7d7b2CompareJanuary 26, 2021 18:04
@nextcloudnextcloud deleted a comment from faily-botBotJan 26, 2021
This was referenced Jan 27, 2021
@rullzerrullzer modified the milestones: Nextcloud 21, Nextcloud 22Feb 2, 2021
@rullzer

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

Rebased

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

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
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 🙈

@MorrisJobkeMorrisJobke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See inline.

@MorrisJobkeMorrisJobke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@MorrisJobke

Copy link
Copy Markdown
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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@icewind1991@blizzz@rullzer@MorrisJobke