fix(container): Log the deprecation to the app when possible

Signed-off-by: Joas Schilling <coding@schilljs.com>
techdebt/noid/reduce-deprecation-spam
Joas Schilling 9 months ago
parent 117d8dea0a
commit 17c40b9474
No known key found for this signature in database
GPG Key ID: F72FA5B49FFA96B0
  1. 2
      lib/private/AppFramework/DependencyInjection/DIContainer.php
  2. 4
      lib/private/AppFramework/Utility/SimpleContainer.php

@ -63,7 +63,7 @@ use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
class DIContainer extends SimpleContainer implements IAppContainer {
private string $appName;
protected string $appName;
private array $middleWares = [];
private ServerContainer $server;

@ -196,7 +196,9 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer {
$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias): mixed {
try {
$logger = $container->get(LoggerInterface::class);
$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', [
'app' => $this->appName ?? 'serverDI',
]);
} catch (ContainerExceptionInterface $e) {
// Could not get logger. Continue
}

Loading…
Cancel
Save