Skip to content

Commit

Permalink
wip: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
luceos committed Feb 24, 2025
1 parent 2ac40e3 commit 06eab34
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
31 changes: 23 additions & 8 deletions framework/core/src/Admin/Middleware/GatherDebugInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,44 @@ public function __construct(protected SettingsRepositoryInterface $settings)

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(protected OutputInterface $output)

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
Expand Down
2 changes: 1 addition & 1 deletion framework/core/src/Foundation/Info/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,28 @@
use Flarum\Foundation\Info\SectionInterface;
use Flarum\Settings\SettingsRepositoryInterface;

class Webserver implements SectionInterface
class ServiceUsers implements SectionInterface
{
public function __construct(protected SettingsRepositoryInterface $settings)
{
}

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);
}
}

0 comments on commit 06eab34

Please sign in to comment.