diff options
-rw-r--r-- | apps/settings/lib/Controller/AppSettingsController.php | 2 | ||||
-rw-r--r-- | lib/private/Installer.php | 7 | ||||
-rw-r--r-- | lib/private/L10N/Factory.php | 48 | ||||
-rw-r--r-- | lib/private/Route/CachingRouter.php | 6 | ||||
-rw-r--r-- | lib/private/Route/Router.php | 25 | ||||
-rw-r--r-- | lib/private/Server.php | 3 | ||||
-rw-r--r-- | tests/lib/AppTest.php | 1 |
7 files changed, 37 insertions, 55 deletions
diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index 9dfe4772b93..2d6697c7d29 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -402,7 +402,7 @@ class AppSettingsController extends Controller { try { $this->appManager->getAppPath($app['id']); $existsLocally = true; - } catch (AppPathNotFoundException $e) { + } catch (AppPathNotFoundException) { $existsLocally = false; } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 6ab497b9dea..c4af480d4ca 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -560,12 +560,13 @@ class Installer { if ($output instanceof IOutput) { $output->debug('Installing ' . $app); } - //install the database - $appPath = OC_App::getAppPath($app); - \OC_App::registerAutoloading($app, $appPath); + $appManager = \OCP\Server::get(IAppManager::class); $config = \OCP\Server::get(IConfig::class); + $appPath = $appManager->getAppPath($app); + \OC_App::registerAutoloading($app, $appPath); + $ms = new MigrationService($app, \OCP\Server::get(Connection::class)); if ($output instanceof IOutput) { $ms->setOutput($output); diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index a9717b679ed..16595ad9385 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -40,6 +40,8 @@ declare(strict_types=1); namespace OC\L10N; +use OCP\App\AppPathNotFoundException; +use OCP\App\IAppManager; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; @@ -88,38 +90,17 @@ class Factory implements IFactory { 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko' ]; - /** @var IConfig */ - protected $config; - - /** @var IRequest */ - protected $request; - - /** @var IUserSession */ - protected IUserSession $userSession; - private ICache $cache; - /** @var string */ - protected $serverRoot; - - /** - * @param IConfig $config - * @param IRequest $request - * @param IUserSession $userSession - * @param string $serverRoot - */ public function __construct( - IConfig $config, - IRequest $request, - IUserSession $userSession, + protected IConfig $config, + protected IRequest $request, + protected IUserSession $userSession, ICacheFactory $cacheFactory, - $serverRoot + protected string $serverRoot, + protected IAppManager $appManager, ) { - $this->config = $config; - $this->request = $request; - $this->userSession = $userSession; $this->cache = $cacheFactory->createLocal('L10NFactory'); - $this->serverRoot = $serverRoot; } /** @@ -562,9 +543,7 @@ class Factory implements IFactory { * @param string $lang * @return string[] */ - // FIXME This method is only public, until OC_L10N does not need it anymore, - // FIXME This is also the reason, why it is not in the public interface - public function getL10nFilesForApp($app, $lang) { + private function getL10nFilesForApp($app, $lang) { $languageFiles = []; $i18nDir = $this->findL10nDir($app); @@ -572,7 +551,7 @@ class Factory implements IFactory { if (($this->isSubDirectory($transFile, $this->serverRoot . '/core/l10n/') || $this->isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/') - || $this->isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/')) + || $this->isSubDirectory($transFile, $this->appManager->getAppPath($app) . '/l10n/')) && file_exists($transFile) ) { // load the translations file @@ -602,9 +581,12 @@ class Factory implements IFactory { if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) { return $this->serverRoot . '/' . $app . '/l10n/'; } - } elseif ($app && \OC_App::getAppPath($app) !== false) { - // Check if the app is in the app folder - return \OC_App::getAppPath($app) . '/l10n/'; + } elseif ($app) { + try { + return $this->appManager->getAppPath($app) . '/l10n/'; + } catch (AppPathNotFoundException) { + /* App not found, continue */ + } } return $this->serverRoot . '/core/l10n/'; } diff --git a/lib/private/Route/CachingRouter.php b/lib/private/Route/CachingRouter.php index 69fb3c986c9..78f05b1f80a 100644 --- a/lib/private/Route/CachingRouter.php +++ b/lib/private/Route/CachingRouter.php @@ -24,6 +24,7 @@ */ namespace OC\Route; +use OCP\App\IAppManager; use OCP\Diagnostics\IEventLogger; use OCP\ICache; use OCP\ICacheFactory; @@ -41,10 +42,11 @@ class CachingRouter extends Router { IRequest $request, IConfig $config, IEventLogger $eventLogger, - ContainerInterface $container + ContainerInterface $container, + IAppManager $appManager, ) { $this->cache = $cacheFactory->createLocal('route'); - parent::__construct($logger, $request, $config, $eventLogger, $container); + parent::__construct($logger, $request, $config, $eventLogger, $container, $appManager); } /** diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index 28a25b4addf..90a6d85d8b5 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -35,6 +35,8 @@ namespace OC\Route; use DirectoryIterator; use OC\AppFramework\Routing\RouteParser; +use OCP\App\AppPathNotFoundException; +use OCP\App\IAppManager; use OCP\AppFramework\App; use OCP\AppFramework\Http\Attribute\Route as RouteAttribute; use OCP\Diagnostics\IEventLogger; @@ -71,22 +73,17 @@ class Router implements IRouter { protected $loaded = false; /** @var array */ protected $loadedApps = []; - protected LoggerInterface $logger; /** @var RequestContext */ protected $context; - private IEventLogger $eventLogger; - private IConfig $config; - private ContainerInterface $container; public function __construct( - LoggerInterface $logger, + protected LoggerInterface $logger, IRequest $request, - IConfig $config, - IEventLogger $eventLogger, - ContainerInterface $container + private IConfig $config, + private IEventLogger $eventLogger, + private ContainerInterface $container, + private IAppManager $appManager, ) { - $this->logger = $logger; - $this->config = $config; $baseUrl = \OC::$WEBROOT; if (!($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { $baseUrl .= '/index.php'; @@ -101,8 +98,6 @@ class Router implements IRouter { $this->context = new RequestContext($baseUrl, $method, $host, $schema); // TODO cache $this->root = $this->getCollection('root'); - $this->eventLogger = $eventLogger; - $this->container = $container; } /** @@ -114,12 +109,14 @@ class Router implements IRouter { if ($this->routingFiles === null) { $this->routingFiles = []; foreach (\OC_APP::getEnabledApps() as $app) { - $appPath = \OC_App::getAppPath($app); - if ($appPath !== false) { + try { + $appPath = $this->appManager->getAppPath($app); $file = $appPath . '/appinfo/routes.php'; if (file_exists($file)) { $this->routingFiles[$app] = $file; } + } catch (AppPathNotFoundException) { + /* ignore */ } } } diff --git a/lib/private/Server.php b/lib/private/Server.php index 3fb14ebca18..2257513147c 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -653,7 +653,8 @@ class Server extends ServerContainer implements IServerContainer { $c->getRequest(), $c->get(IUserSession::class), $c->get(ICacheFactory::class), - \OC::$SERVERROOT + \OC::$SERVERROOT, + $c->get(IAppManager::class), ); }); /** @deprecated 19.0.0 */ diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 4e723e5d2f1..06331700737 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -560,7 +560,6 @@ class AppTest extends \Test\TestCase { $this->overwriteService(AppManager::class, new AppManager( \OC::$server->getUserSession(), \OC::$server->getConfig(), - $appConfig, \OC::$server->getGroupManager(), \OC::$server->getMemCacheFactory(), \OC::$server->get(IEventDispatcher::class), |