mirror of
https://github.com/flarum/framework.git
synced 2025-03-07 02:37:48 +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
|
public function process(Request $request, Handler $handler): Response
|
||||||
{
|
{
|
||||||
// Read current web user, so we can compare that against CLI executions,
|
$this->upsertWebUser();
|
||||||
// these often cause file permission issues.
|
|
||||||
|
$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');
|
$user = $this->settings->get('core.debug.web_user');
|
||||||
$currentUser = get_current_user();
|
$currentUser = get_current_user();
|
||||||
|
|
||||||
if ($user !== $currentUser) {
|
if ($user !== $currentUser) {
|
||||||
$this->settings->set(
|
$this->settings->set(
|
||||||
'core.debug.web_user',
|
'core.debug.web_user',
|
||||||
$currentUser
|
$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');
|
$opcache = $this->settings->get('core.debug.opcache');
|
||||||
$opcacheStatus = function_exists('opcache_get_configuration')
|
$opcacheStatus = function_exists('opcache_get_configuration') && opcache_get_configuration() !== false ? 'on' : 'off';
|
||||||
&& opcache_get_configuration() !== false ? 'on' : 'off';
|
|
||||||
if ($opcache !== $opcacheStatus) {
|
if ($opcache !== $opcacheStatus) {
|
||||||
$this->settings->set(
|
$this->settings->set(
|
||||||
'core.debug.opcache',
|
'core.debug.opcache',
|
||||||
$opcacheStatus
|
$opcacheStatus
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $handler->handle($request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class CliRenderer implements RendererInterface
|
|||||||
|
|
||||||
public function heading(string $title): void
|
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
|
public function keyValue(string $key, mixed $value): void
|
||||||
|
@ -19,8 +19,8 @@ class Report
|
|||||||
Section\Database::class,
|
Section\Database::class,
|
||||||
Section\EnabledExtensions::class,
|
Section\EnabledExtensions::class,
|
||||||
Section\Features::class,
|
Section\Features::class,
|
||||||
Section\Webserver::class,
|
|
||||||
Section\Debug::class,
|
Section\Debug::class,
|
||||||
|
Section\ServiceUsers::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -13,7 +13,7 @@ use Flarum\Foundation\Info\RendererInterface;
|
|||||||
use Flarum\Foundation\Info\SectionInterface;
|
use Flarum\Foundation\Info\SectionInterface;
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
|
|
||||||
class Webserver implements SectionInterface
|
class ServiceUsers implements SectionInterface
|
||||||
{
|
{
|
||||||
public function __construct(protected SettingsRepositoryInterface $settings)
|
public function __construct(protected SettingsRepositoryInterface $settings)
|
||||||
{
|
{
|
||||||
@ -21,9 +21,20 @@ class Webserver implements SectionInterface
|
|||||||
|
|
||||||
public function __invoke(RendererInterface $renderer): void
|
public function __invoke(RendererInterface $renderer): void
|
||||||
{
|
{
|
||||||
$renderer->keyValue(
|
$rows = [
|
||||||
'Web user',
|
['Web user', $this->settings->get('core.debug.web_user') ?? 'visit admin to identify']
|
||||||
$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