Merge pull request #54339 from nextcloud/techdebt/noid/reduce-deprecation-spam-2

fix(container): Reduce general deprecation spam on all requests
pull/54348/head
Joas Schilling 2 months ago committed by GitHub
commit 44b4741384
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
  2. 6
      apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php
  3. 13
      build/psalm-baseline.xml
  4. 3
      lib/private/AppFramework/DependencyInjection/DIContainer.php
  5. 22
      lib/private/InitialStateService.php
  6. 38
      lib/private/UserStatus/Manager.php
  7. 8
      lib/public/IInitialStateService.php

@ -11,35 +11,24 @@ namespace OCA\TwoFactorBackupCodes\Provider;
use OC\App\AppManager;
use OCA\TwoFactorBackupCodes\Service\BackupCodeStorage;
use OCA\TwoFactorBackupCodes\Settings\Personal;
use OCP\AppFramework\Services\IInitialState;
use OCP\Authentication\TwoFactorAuth\IDeactivatableByAdmin;
use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings;
use OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IUser;
use OCP\Template\ITemplate;
use OCP\Template\ITemplateManager;
class BackupCodesProvider implements IDeactivatableByAdmin, IProvidesPersonalSettings {
/** @var AppManager */
private $appManager;
/**
* @param string $appName
* @param BackupCodeStorage $storage
* @param IL10N $l10n
* @param AppManager $appManager
*/
public function __construct(
private string $appName,
private BackupCodeStorage $storage,
private IL10N $l10n,
AppManager $appManager,
private IInitialStateService $initialStateService,
private AppManager $appManager,
private IInitialState $initialState,
private ITemplateManager $templateManager,
) {
$this->appManager = $appManager;
}
/**
@ -131,11 +120,11 @@ class BackupCodesProvider implements IDeactivatableByAdmin, IProvidesPersonalSet
*/
public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
$state = $this->storage->getBackupCodesState($user);
$this->initialStateService->provideInitialState($this->appName, 'state', $state);
$this->initialState->provideInitialState('state', $state);
return new Personal();
}
public function disableFor(IUser $user) {
public function disableFor(IUser $user): void {
$this->storage->deleteCodes($user);
}
}

@ -11,7 +11,7 @@ namespace OCA\TwoFactorBackupCodes\Tests\Unit\Provider;
use OC\App\AppManager;
use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider;
use OCA\TwoFactorBackupCodes\Service\BackupCodeStorage;
use OCP\IInitialStateService;
use OCP\AppFramework\Services\IInitialState;
use OCP\IL10N;
use OCP\IUser;
use OCP\Server;
@ -25,7 +25,7 @@ class BackupCodesProviderTest extends TestCase {
private BackupCodeStorage&MockObject $storage;
private IL10N&MockObject $l10n;
private AppManager&MockObject $appManager;
private IInitialStateService&MockObject $initialState;
private IInitialState&MockObject $initialState;
private ITemplateManager $templateManager;
private BackupCodesProvider $provider;
@ -37,7 +37,7 @@ class BackupCodesProviderTest extends TestCase {
$this->storage = $this->createMock(BackupCodeStorage::class);
$this->l10n = $this->createMock(IL10N::class);
$this->appManager = $this->createMock(AppManager::class);
$this->initialState = $this->createMock(IInitialStateService::class);
$this->initialState = $this->createMock(IInitialState::class);
$this->templateManager = Server::get(ITemplateManager::class);
$this->provider = new BackupCodesProvider(

@ -2424,14 +2424,6 @@
<code><![CDATA[getName]]></code>
</DeprecatedMethod>
</file>
<file src="apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php">
<DeprecatedInterface>
<code><![CDATA[private]]></code>
</DeprecatedInterface>
<DeprecatedMethod>
<code><![CDATA[provideInitialState]]></code>
</DeprecatedMethod>
</file>
<file src="apps/user_ldap/ajax/clearMappings.php">
<DeprecatedMethod>
<code><![CDATA[\OC_JSON::callCheck()]]></code>
@ -4013,6 +4005,11 @@
<code><![CDATA[isAdmin]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/private/InitialStateService.php">
<UndefinedInterfaceMethod>
<code><![CDATA[query]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/private/Installer.php">
<InvalidArgument>
<code><![CDATA[false]]></code>

@ -38,6 +38,7 @@ use OC\Log\PsrLoggerAdapter;
use OC\ServerContainer;
use OC\Settings\AuthorizedGroupMapper;
use OCA\WorkflowEngine\Manager;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\IOutput;
use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\QueryException;
@ -200,7 +201,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
$server->getUserSession()->isLoggedIn(),
$c->get(IGroupManager::class),
$c->get(ISubAdmin::class),
$server->getAppManager(),
$c->get(IAppManager::class),
$server->getL10N('lib'),
$c->get(AuthorizedGroupMapper::class),
$c->get(IUserSession::class),

@ -13,29 +13,23 @@ use OC\AppFramework\Bootstrap\Coordinator;
use OCP\AppFramework\QueryException;
use OCP\AppFramework\Services\InitialStateProvider;
use OCP\IInitialStateService;
use OCP\IServerContainer;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
class InitialStateService implements IInitialStateService {
/** @var LoggerInterface */
private $logger;
/** @var string[][] */
private $states = [];
private array $states = [];
/** @var Closure[][] */
private $lazyStates = [];
private array $lazyStates = [];
/** @var Coordinator */
private $bootstrapCoordinator;
/** @var IServerContainer */
private $container;
public function __construct(LoggerInterface $logger, Coordinator $bootstrapCoordinator, IServerContainer $container) {
$this->logger = $logger;
$this->bootstrapCoordinator = $bootstrapCoordinator;
$this->container = $container;
public function __construct(
private LoggerInterface $logger,
private Coordinator $bootstrapCoordinator,
private ContainerInterface $container,
) {
}
public function provideInitialState(string $appName, string $key, $data): void {

@ -8,35 +8,21 @@ declare(strict_types=1);
*/
namespace OC\UserStatus;
use OCP\IServerContainer;
use OCP\UserStatus\IManager;
use OCP\UserStatus\IProvider;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
class Manager implements IManager {
/** @var IServerContainer */
private $container;
/** @var LoggerInterface */
private $logger;
/** @var class-string */
private $providerClass;
/** @var IProvider */
private $provider;
/**
* Manager constructor.
*
* @param IServerContainer $container
* @param LoggerInterface $logger
*/
public function __construct(IServerContainer $container,
LoggerInterface $logger) {
$this->container = $container;
$this->logger = $logger;
/** @var ?class-string */
private ?string $providerClass = null;
private ?IProvider $provider = null;
public function __construct(
private ContainerInterface $container,
private LoggerInterface $logger,
) {
}
/**
@ -89,7 +75,7 @@ class Manager implements IManager {
public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup = false, ?string $customMessage = null): void {
$this->setupProvider();
if (!$this->provider || !($this->provider instanceof ISettableProvider)) {
if (!$this->provider instanceof ISettableProvider) {
return;
}
@ -98,7 +84,7 @@ class Manager implements IManager {
public function revertUserStatus(string $userId, string $messageId, string $status): void {
$this->setupProvider();
if (!$this->provider || !($this->provider instanceof ISettableProvider)) {
if (!$this->provider instanceof ISettableProvider) {
return;
}
$this->provider->revertUserStatus($userId, $messageId, $status);
@ -106,7 +92,7 @@ class Manager implements IManager {
public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void {
$this->setupProvider();
if (!$this->provider || !($this->provider instanceof ISettableProvider)) {
if (!$this->provider instanceof ISettableProvider) {
return;
}
$this->provider->revertMultipleUserStatus($userIds, $messageId, $status);

@ -11,13 +11,13 @@ use Closure;
/**
* @since 16.0.0
* @deprecated 21 Use OCP\AppFramework\Services\IInitialState or OCP\AppFramework\Services\InitialStateProvider
* @deprecated 21 Use {@see \OCP\AppFramework\Services\IInitialState} or {@see \OCP\AppFramework\Services\InitialStateProvider}
* @see \OCP\AppFramework\Services\IInitialState
*/
interface IInitialStateService {
/**
* Allows an app to provide its initial state to the template system.
* Use this if you know your initial state sill be used for example if
* Use this if you know your initial state still be used for example if
* you are in the render function of you controller.
*
* @since 16.0.0
@ -26,7 +26,7 @@ interface IInitialStateService {
* @param string $key
* @param bool|int|float|string|array|\JsonSerializable $data
*
* @deprecated 21 Use OCP\AppFramework\Services\IInitialState or OCP\AppFramework\Services\InitialStateProvider
* @deprecated 21 Use {@see \OCP\AppFramework\Services\IInitialState} or {@see \OCP\AppFramework\Services\InitialStateProvider}
* @see \OCP\AppFramework\Services\IInitialState::provideInitialState()
*/
public function provideInitialState(string $appName, string $key, $data): void;
@ -44,7 +44,7 @@ interface IInitialStateService {
* @param string $key
* @param Closure $closure returns a primitive or an object that implements JsonSerializable
*
* @deprecated 21 Use OCP\AppFramework\Services\IInitialState or OCP\AppFramework\Services\InitialStateProvider
* @deprecated 21 Use {@see \OCP\AppFramework\Services\IInitialState} or {@see \OCP\AppFramework\Services\InitialStateProvider}
* @see \OCP\AppFramework\Services\IInitialState::provideLazyInitialState()
*/
public function provideLazyInitialState(string $appName, string $key, Closure $closure): void;

Loading…
Cancel
Save