fix: Remove static vars usage in user_ldap
There are still some left, harder to remove. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
@@ -444,13 +444,9 @@ class Configuration {
|
||||
}
|
||||
|
||||
protected function getValue(string $varName): string {
|
||||
static $defaults;
|
||||
if (is_null($defaults)) {
|
||||
$defaults = $this->getDefaults();
|
||||
}
|
||||
return Server::get(IConfig::class)->getAppValue('user_ldap',
|
||||
$this->configPrefix . $varName,
|
||||
$defaults[$varName]);
|
||||
$this->getDefaults()[$varName]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace OCA\User_LDAP\Mapping;
|
||||
|
||||
use OCP\HintException;
|
||||
@@ -12,7 +15,6 @@ use OCP\IAppConfig;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IRequest;
|
||||
use OCP\Server;
|
||||
use OCP\Support\Subscription\IAssertion;
|
||||
|
||||
/**
|
||||
@@ -30,6 +32,7 @@ class UserMapping extends AbstractMapping {
|
||||
IAppConfig $config,
|
||||
bool $isCLI,
|
||||
private IAssertion $assertion,
|
||||
private IRequest $request,
|
||||
) {
|
||||
parent::__construct($dbc, $cacheFactory, $config, $isCLI);
|
||||
}
|
||||
@@ -41,13 +44,7 @@ class UserMapping extends AbstractMapping {
|
||||
try {
|
||||
$this->assertion->createUserIsLegit();
|
||||
} catch (HintException $e) {
|
||||
static $isProvisioningApi = null;
|
||||
|
||||
if ($isProvisioningApi === null) {
|
||||
$request = Server::get(IRequest::class);
|
||||
$isProvisioningApi = \preg_match(self::PROV_API_REGEX, $request->getRequestUri()) === 1;
|
||||
}
|
||||
if ($isProvisioningApi) {
|
||||
if (\preg_match(self::PROV_API_REGEX, $this->request->getRequestUri()) === 1) {
|
||||
// only throw when prov API is being used, since functionality
|
||||
// should not break for end users (e.g. when sharing).
|
||||
// On direct API usage, e.g. on users page, this is desired.
|
||||
|
||||
@@ -12,6 +12,7 @@ use OCA\User_LDAP\Mapping\UserMapping;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IRequest;
|
||||
use OCP\Support\Subscription\IAssertion;
|
||||
|
||||
/**
|
||||
@@ -23,6 +24,6 @@ use OCP\Support\Subscription\IAssertion;
|
||||
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
|
||||
class UserMappingTest extends AbstractMappingTestCase {
|
||||
public function getMapper(IDBConnection $dbMock, ICacheFactory $cacheFactory, IAppConfig $appConfig): UserMapping {
|
||||
return new UserMapping($dbMock, $cacheFactory, $appConfig, true, $this->createMock(IAssertion::class));
|
||||
return new UserMapping($dbMock, $cacheFactory, $appConfig, true, $this->createMock(IAssertion::class), $this->createMock(IRequest::class));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user