mirror of
https://github.com/flarum/framework.git
synced 2025-03-06 18:21:46 +08:00
wip: clean up
This commit is contained in:
parent
2ac40e3e03
commit
06eab34a30
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class CliRenderer implements RendererInterface
|
||||
|
||||
public function heading(string $title): void
|
||||
{
|
||||
$this->output->writeln("<bg=gray,options=bold>$title</>");
|
||||
$this->output->writeln("<bg=gray>$title</>");
|
||||
}
|
||||
|
||||
public function keyValue(string $key, mixed $value): void
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user