From a1e1f6ad335dfbb952a03d30b585086d3a66831f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Tue, 31 Dec 2024 17:57:29 +0100 Subject: [PATCH] additions --- .../Middleware/GatherDebugInformation.php | 9 ++++--- framework/core/src/Foundation/Info/Report.php | 2 ++ .../src/Foundation/Info/Section/Database.php | 27 +++++++++++++++++++ .../src/Foundation/Info/Section/Features.php | 4 ++- .../core/src/Foundation/Info/Section/PHP.php | 12 +++++++-- .../src/Foundation/Info/Section/Webserver.php | 22 +++++++++++++++ 6 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 framework/core/src/Foundation/Info/Section/Database.php create mode 100644 framework/core/src/Foundation/Info/Section/Webserver.php diff --git a/framework/core/src/Admin/Middleware/GatherDebugInformation.php b/framework/core/src/Admin/Middleware/GatherDebugInformation.php index ac5fa9de8..2e4dc518b 100644 --- a/framework/core/src/Admin/Middleware/GatherDebugInformation.php +++ b/framework/core/src/Admin/Middleware/GatherDebugInformation.php @@ -29,18 +29,19 @@ class GatherDebugInformation implements Middleware $currentUser = get_current_user(); if ($user !== $currentUser) { $this->settings->set( - 'core.web_user', + "core.debug.web_user", $currentUser ); } // Read the opcache situation, this is only visible in web. - $opcache = $this->settings->get('core.debug.opcache_enabled'); + // Cli has opcache disabled by default. + $opcache = $this->settings->get('core.debug.opcache'); $opcacheStatus = function_exists('opcache_get_configuration') - && opcache_get_configuration() !== false; + && opcache_get_configuration() !== false ? 'on' : 'off'; if ($opcache !== $opcacheStatus) { $this->settings->set( - 'core.debug.opcache_enabled', + 'core.debug.opcache', $opcacheStatus ); } diff --git a/framework/core/src/Foundation/Info/Report.php b/framework/core/src/Foundation/Info/Report.php index 1ca8147e3..37f0fa881 100644 --- a/framework/core/src/Foundation/Info/Report.php +++ b/framework/core/src/Foundation/Info/Report.php @@ -16,8 +16,10 @@ class Report protected array $sections = [ Section\CoreVersion::class, Section\PHP::class, + Section\Database::class, Section\EnabledExtensions::class, Section\Features::class, + Section\Webserver::class, Section\Debug::class, ]; diff --git a/framework/core/src/Foundation/Info/Section/Database.php b/framework/core/src/Foundation/Info/Section/Database.php new file mode 100644 index 000000000..0d6fa3918 --- /dev/null +++ b/framework/core/src/Foundation/Info/Section/Database.php @@ -0,0 +1,27 @@ +keyValue( + 'Database driver', + $this->appInfo->identifyDatabaseDriver() + ); + + $renderer->keyValue( + 'Database version', + $this->appInfo->identifyDatabaseVersion() + ); + } +} diff --git a/framework/core/src/Foundation/Info/Section/Features.php b/framework/core/src/Foundation/Info/Section/Features.php index b5fdd7d6f..6034f875d 100644 --- a/framework/core/src/Foundation/Info/Section/Features.php +++ b/framework/core/src/Foundation/Info/Section/Features.php @@ -13,12 +13,14 @@ use Flarum\Foundation\ApplicationInfoProvider; use Flarum\Foundation\Info\RendererInterface; use Flarum\Foundation\Info\SectionInterface; use Flarum\Mail\NullDriver; +use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Container\Container; class Features implements SectionInterface { public function __construct( protected ApplicationInfoProvider $appInfo, + protected SettingsRepositoryInterface $settings, protected Container $container ) { } @@ -54,7 +56,7 @@ class Features implements SectionInterface protected function mail() { $driver = $this->container->make('mail.driver'); - $configured = $this->container->make('flarum.mail.configured_driver'); + $configured = $this->settings->get('mail_driver'); if ($driver instanceof NullDriver) { $configured .= ' (not active)'; diff --git a/framework/core/src/Foundation/Info/Section/PHP.php b/framework/core/src/Foundation/Info/Section/PHP.php index 718d7388f..05928ee7e 100644 --- a/framework/core/src/Foundation/Info/Section/PHP.php +++ b/framework/core/src/Foundation/Info/Section/PHP.php @@ -12,11 +12,14 @@ namespace Flarum\Foundation\Info\Section; use Flarum\Foundation\ApplicationInfoProvider; use Flarum\Foundation\Info\RendererInterface; use Flarum\Foundation\Info\SectionInterface; +use Flarum\Settings\SettingsRepositoryInterface; class PHP implements SectionInterface { - public function __construct(protected ApplicationInfoProvider $appInfo) - { + public function __construct( + protected ApplicationInfoProvider $appInfo, + protected SettingsRepositoryInterface $settings + ) { } public function __invoke(RendererInterface $renderer): void @@ -30,5 +33,10 @@ class PHP implements SectionInterface 'PHP extensions', implode(', ', get_loaded_extensions()) ); + + $renderer->keyValue( + 'PHP OpCache', + $this->settings->get('core.debug.opcache') ?? 'visit admin to identify' + ); } } diff --git a/framework/core/src/Foundation/Info/Section/Webserver.php b/framework/core/src/Foundation/Info/Section/Webserver.php new file mode 100644 index 000000000..9721978cf --- /dev/null +++ b/framework/core/src/Foundation/Info/Section/Webserver.php @@ -0,0 +1,22 @@ +keyValue( + 'Web user', + $this->settings->get('core.debug.web_user') ?? 'visit admin to identify' + ); + } +}