Skip to content

Commit bceeb31

Browse files
authored
Merge pull request #38027 from nextcloud/backport/37903/stable26
[stable26] Fix multiple LDAP configuration support by fixing AccessFactory
2 parents 83d060a + 77f1ba9 commit bceeb31

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

apps/user_ldap/lib/AccessFactory.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,35 @@
2626
use OCA\User_LDAP\User\Manager;
2727
use OCP\IConfig;
2828
use OCP\IUserManager;
29+
use OCP\Server;
2930
use Psr\Log\LoggerInterface;
3031

3132
class AccessFactory {
3233
private ILDAPWrapper $ldap;
33-
private Manager $userManager;
3434
private Helper $helper;
3535
private IConfig $config;
3636
private IUserManager $ncUserManager;
3737
private LoggerInterface $logger;
3838

3939
public function __construct(
4040
ILDAPWrapper $ldap,
41-
Manager $userManager,
4241
Helper $helper,
4342
IConfig $config,
4443
IUserManager $ncUserManager,
4544
LoggerInterface $logger) {
4645
$this->ldap = $ldap;
47-
$this->userManager = $userManager;
4846
$this->helper = $helper;
4947
$this->config = $config;
5048
$this->ncUserManager = $ncUserManager;
5149
$this->logger = $logger;
5250
}
5351

5452
public function get(Connection $connection): Access {
53+
/* Each Access instance gets its own Manager instance, see OCA\User_LDAP\AppInfo\Application::register() */
5554
return new Access(
5655
$connection,
5756
$this->ldap,
58-
$this->userManager,
57+
Server::get(Manager::class),
5958
$this->helper,
6059
$this->config,
6160
$this->ncUserManager,

apps/user_ldap/lib/Jobs/Sync.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use OCA\User_LDAP\Helper;
3232
use OCA\User_LDAP\LDAP;
3333
use OCA\User_LDAP\Mapping\UserMapping;
34-
use OCA\User_LDAP\User\Manager;
3534
use OCP\AppFramework\Utility\ITimeFactory;
3635
use OCP\BackgroundJob\TimedJob;
3736
use OCP\IAvatarManager;
@@ -48,8 +47,6 @@ class Sync extends TimedJob {
4847
protected $ldapHelper;
4948
/** @var LDAP */
5049
protected $ldap;
51-
/** @var Manager */
52-
protected $userManager;
5350
/** @var UserMapping */
5451
protected $mapper;
5552
/** @var IConfig */
@@ -69,9 +66,8 @@ class Sync extends TimedJob {
6966
/** @var AccessFactory */
7067
protected $accessFactory;
7168

72-
public function __construct(Manager $userManager, ITimeFactory $time) {
69+
public function __construct(ITimeFactory $time) {
7370
parent::__construct($time);
74-
$this->userManager = $userManager;
7571
$this->setInterval(
7672
\OC::$server->getConfig()->getAppValue(
7773
'user_ldap',
@@ -350,10 +346,6 @@ public function setArgument($argument) {
350346
$this->notificationManager = \OC::$server->getNotificationManager();
351347
}
352348

353-
if (isset($argument['userManager'])) {
354-
$this->userManager = $argument['userManager'];
355-
}
356-
357349
if (isset($argument['mapper'])) {
358350
$this->mapper = $argument['mapper'];
359351
} else {
@@ -369,14 +361,7 @@ public function setArgument($argument) {
369361
if (isset($argument['accessFactory'])) {
370362
$this->accessFactory = $argument['accessFactory'];
371363
} else {
372-
$this->accessFactory = new AccessFactory(
373-
$this->ldap,
374-
$this->userManager,
375-
$this->ldapHelper,
376-
$this->config,
377-
$this->ncUserManager,
378-
$this->logger
379-
);
364+
$this->accessFactory = \OCP\Server::get(AccessFactory::class);
380365
}
381366
}
382367
}

apps/user_ldap/tests/Jobs/SyncTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
use Test\TestCase;
4444

4545
class SyncTest extends TestCase {
46-
4746
/** @var array */
4847
protected $arguments;
4948
/** @var Helper|\PHPUnit\Framework\MockObject\MockObject */
@@ -99,7 +98,7 @@ protected function setUp(): void {
9998
'accessFactory' => $this->accessFactory,
10099
];
101100

102-
$this->sync = new Sync($this->userManager, $this->createMock(ITimeFactory::class));
101+
$this->sync = new Sync($this->createMock(ITimeFactory::class));
103102
}
104103

105104
public function intervalDataProvider() {

0 commit comments

Comments
 (0)