Skip to content

Commit

Permalink
Merge pull request #27736 from nextcloud/backport/27732/stable22
Browse files Browse the repository at this point in the history
[stable22] Fix LDAPProviderFactory not found
  • Loading branch information
blizzz authored Jun 30, 2021
2 parents 28a2104 + 87d8e8f commit 9882ae8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apps/user_ldap/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ A user logs into Nextcloud with their LDAP or AD credentials, and is granted acc
<install>
<step>OCA\User_LDAP\Migration\SetDefaultProvider</step>
</install>
<uninstall>
<step>OCA\User_LDAP\Migration\UnsetDefaultProvider</step>
</uninstall>
<post-migration>
<step>OCA\User_LDAP\Migration\UUIDFixInsert</step>
<step>OCA\User_LDAP\Migration\RemoveRefreshTime</step>
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
'OCA\\User_LDAP\\Migration\\UUIDFixGroup' => $baseDir . '/../lib/Migration/UUIDFixGroup.php',
'OCA\\User_LDAP\\Migration\\UUIDFixInsert' => $baseDir . '/../lib/Migration/UUIDFixInsert.php',
'OCA\\User_LDAP\\Migration\\UUIDFixUser' => $baseDir . '/../lib/Migration/UUIDFixUser.php',
'OCA\\User_LDAP\\Migration\\UnsetDefaultProvider' => $baseDir . '/../lib/Migration/UnsetDefaultProvider.php',
'OCA\\User_LDAP\\Migration\\Version1010Date20200630192842' => $baseDir . '/../lib/Migration/Version1010Date20200630192842.php',
'OCA\\User_LDAP\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
'OCA\\User_LDAP\\PagedResults\\IAdapter' => $baseDir . '/../lib/PagedResults/IAdapter.php',
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class ComposerStaticInitUser_LDAP
'OCA\\User_LDAP\\Migration\\UUIDFixGroup' => __DIR__ . '/..' . '/../lib/Migration/UUIDFixGroup.php',
'OCA\\User_LDAP\\Migration\\UUIDFixInsert' => __DIR__ . '/..' . '/../lib/Migration/UUIDFixInsert.php',
'OCA\\User_LDAP\\Migration\\UUIDFixUser' => __DIR__ . '/..' . '/../lib/Migration/UUIDFixUser.php',
'OCA\\User_LDAP\\Migration\\UnsetDefaultProvider' => __DIR__ . '/..' . '/../lib/Migration/UnsetDefaultProvider.php',
'OCA\\User_LDAP\\Migration\\Version1010Date20200630192842' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630192842.php',
'OCA\\User_LDAP\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
'OCA\\User_LDAP\\PagedResults\\IAdapter' => __DIR__ . '/..' . '/../lib/PagedResults/IAdapter.php',
Expand Down
52 changes: 52 additions & 0 deletions apps/user_ldap/lib/Migration/UnsetDefaultProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

/**
* @copyright 2021 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\User_LDAP\Migration;

use OCA\User_LDAP\LDAPProviderFactory;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class UnsetDefaultProvider implements IRepairStep {

/** @var IConfig */
private $config;

public function __construct(IConfig $config) {
$this->config = $config;
}

public function getName(): string {
return 'Unset default LDAP provider';
}

public function run(IOutput $output): void {
$current = $this->config->getSystemValue('ldapProviderFactory', null);
if ($current === LDAPProviderFactory::class) {
$this->config->deleteSystemValue('ldapProviderFactory');
}
}
}
2 changes: 1 addition & 1 deletion lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ public function __construct($webRoot, \OC\Config $config) {
$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
$config = $c->get(\OCP\IConfig::class);
$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
if (is_null($factoryClass)) {
if (is_null($factoryClass) || !class_exists($factoryClass)) {
return new NullLDAPProviderFactory($this);
}
/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
Expand Down

0 comments on commit 9882ae8

Please sign in to comment.