diff --git a/framework/core/src/Admin/Middleware/GatherDebugInformation.php b/framework/core/src/Admin/Middleware/GatherDebugInformation.php index 39096485e..af7026645 100644 --- a/framework/core/src/Admin/Middleware/GatherDebugInformation.php +++ b/framework/core/src/Admin/Middleware/GatherDebugInformation.php @@ -23,29 +23,44 @@ class GatherDebugInformation implements Middleware public function process(Request $request, Handler $handler): Response { - // Read current web user, so we can compare that against CLI executions, - // these often cause file permission issues. + $this->upsertWebUser(); + + $this->upsertOpCacheStatus(); + + return $handler->handle($request); + } + + /** + * Read current web user, so we can compare that against CLI executions, + * these often cause file permission issues. + */ + public function upsertWebUser(): void + { $user = $this->settings->get('core.debug.web_user'); $currentUser = get_current_user(); + if ($user !== $currentUser) { $this->settings->set( 'core.debug.web_user', $currentUser ); } + } - // Read the opcache situation, this is only visible in web. - // Cli has opcache disabled by default. + /** + * Read the opcache situation, this is only visible in web. + * Cli has opcache disabled by default. + */ + public function upsertOpCacheStatus(): void + { $opcache = $this->settings->get('core.debug.opcache'); - $opcacheStatus = function_exists('opcache_get_configuration') - && opcache_get_configuration() !== false ? 'on' : 'off'; + $opcacheStatus = function_exists('opcache_get_configuration') && opcache_get_configuration() !== false ? 'on' : 'off'; + if ($opcache !== $opcacheStatus) { $this->settings->set( 'core.debug.opcache', $opcacheStatus ); } - - return $handler->handle($request); } } diff --git a/framework/core/src/Foundation/Info/Renderer/CliRenderer.php b/framework/core/src/Foundation/Info/Renderer/CliRenderer.php index 51108f5b0..1d206027f 100644 --- a/framework/core/src/Foundation/Info/Renderer/CliRenderer.php +++ b/framework/core/src/Foundation/Info/Renderer/CliRenderer.php @@ -22,7 +22,7 @@ class CliRenderer implements RendererInterface public function heading(string $title): void { - $this->output->writeln("$title"); + $this->output->writeln("$title"); } public function keyValue(string $key, mixed $value): void diff --git a/framework/core/src/Foundation/Info/Report.php b/framework/core/src/Foundation/Info/Report.php index 37f0fa881..25aa52738 100644 --- a/framework/core/src/Foundation/Info/Report.php +++ b/framework/core/src/Foundation/Info/Report.php @@ -19,8 +19,8 @@ class Report Section\Database::class, Section\EnabledExtensions::class, Section\Features::class, - Section\Webserver::class, Section\Debug::class, + Section\ServiceUsers::class, ]; public function __construct( diff --git a/framework/core/src/Foundation/Info/Section/Webserver.php b/framework/core/src/Foundation/Info/Section/ServiceUsers.php similarity index 53% rename from framework/core/src/Foundation/Info/Section/Webserver.php rename to framework/core/src/Foundation/Info/Section/ServiceUsers.php index caa126bf9..dd23d6e88 100644 --- a/framework/core/src/Foundation/Info/Section/Webserver.php +++ b/framework/core/src/Foundation/Info/Section/ServiceUsers.php @@ -13,7 +13,7 @@ use Flarum\Foundation\Info\RendererInterface; use Flarum\Foundation\Info\SectionInterface; use Flarum\Settings\SettingsRepositoryInterface; -class Webserver implements SectionInterface +class ServiceUsers implements SectionInterface { public function __construct(protected SettingsRepositoryInterface $settings) { @@ -21,9 +21,20 @@ class Webserver implements SectionInterface public function __invoke(RendererInterface $renderer): void { - $renderer->keyValue( - 'Web user', - $this->settings->get('core.debug.web_user') ?? 'visit admin to identify' - ); + $rows = [ + ['Web user', $this->settings->get('core.debug.web_user') ?? 'visit admin to identify'] + ]; + + if (php_sapi_name() === 'cli') { + $rows[] = [ + 'Current user', + posix_getpwuid(posix_geteuid())['name'] + ]; + } + + $renderer->table([ + ['Service/process users'], + ['Type', 'User'] + ], $rows); } }