From da8abcf5165459cd15108ead8709f770304d8cba Mon Sep 17 00:00:00 2001 From: Niko M Date: Mon, 29 Jun 2026 10:01:58 +1000 Subject: [PATCH 1/2] :ambulance: Fix Internal server error from `OC\\Server::getL10NFactory()` Signed-off-by: Niko M --- lib/AppInfo/Application.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index d1a4cdc7..67abfa1f 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -24,12 +24,10 @@ use OCP\FullTextSearch\IFullTextSearchManager; use OCP\IAppConfig; use OCP\INavigationManager; -use OCP\IServerContainer; use OCP\IURLGenerator; use OCP\L10N\IFactory; -use OCP\Server; -use Symfony\Component\Routing\Exception\RouteNotFoundException; use Psr\Container\ContainerInterface; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Throwable; if (file_exists($autoLoad = __DIR__ . '/../../vendor/autoload.php')) { @@ -91,17 +89,22 @@ protected function registerServices(ContainerInterface $container) { /** * Register Navigation Tab */ - protected function registerNavigation(ContainerInterface $container) { - /** @var IAppConfig $appConfig */ - $appConfig = $container->get(IAppConfig::class); + protected function registerNavigation( + IAppConfig $appConfig, + INavigationManager $navigationManager, + IURLGenerator $urlGen, + IFactory $l10nFactory + ): void { if (!$appConfig->getValueBool(self::APP_ID, ConfigLexicon::APP_NAVIGATION)) { return; } try { - $container->get(INavigationManager::class) - ->add(fn () => $this->fullTextSearchNavigation()); - } catch (\Exception) { + $navigationManager->add( + fn () => $this->fullTextSearchNavigation($urlGen, $l10nFactory) + ); + } catch (RouteNotFoundException) { + // Navigation route not found, do not add navigation entry } } @@ -109,17 +112,13 @@ protected function registerNavigation(ContainerInterface $container) { /** * @return array */ - private function fullTextSearchNavigation(): array { - $urlGen = Server::get(IURLGenerator::class); - + private function fullTextSearchNavigation(IURLGenerator $urlGen, IFactory $l10nFactory): array { return [ 'id' => self::APP_ID, 'order' => 5, 'href' => $urlGen->linkToRoute(self::APP_ID . '.Navigation.navigate'), 'icon' => $urlGen->imagePath(self::APP_ID, 'fulltextsearch.svg'), - 'name' => Server::get(IFactory::class)->get('fulltextsearch')->t('Search') + 'name' => $l10nFactory->get(self::APP_ID)->t('Search') ]; } - } - From fc9aa5a5dd91ebdf912aad5e69f353d875f967cb Mon Sep 17 00:00:00 2001 From: Niko M Date: Mon, 29 Jun 2026 10:02:40 +1000 Subject: [PATCH 2/2] [dev] Add RouteNotFoundException class and update phpstan configuration Signed-off-by: Niko M --- phpstan.neon | 1 + ...uting_exception_routenotfoundexception.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/stubs/symfony_component_routing_exception_routenotfoundexception.php diff --git a/phpstan.neon b/phpstan.neon index 377060e9..170e1e89 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -50,4 +50,5 @@ parameters: - tests/stubs/symfony_component_console_formatter_outputformatterstyle_interface.php - tests/stubs/symfony_component_console_formatter_outputformatterstyle.php - tests/stubs/symfony_component_console_formatter_outputformatterinterface.php + - tests/stubs/symfony_component_routing_exception_routenotfoundexception.php diff --git a/tests/stubs/symfony_component_routing_exception_routenotfoundexception.php b/tests/stubs/symfony_component_routing_exception_routenotfoundexception.php new file mode 100644 index 00000000..7d0874b1 --- /dev/null +++ b/tests/stubs/symfony_component_routing_exception_routenotfoundexception.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Exception; + +class RouteNotFoundException extends \InvalidArgumentException implements ExceptionInterface +{ +} + +interface ExceptionInterface extends \Throwable +{ +}