Refine ACP system health/update checks and CLI PHP validation
This commit is contained in:
@@ -19,11 +19,22 @@ class SystemStatusController extends Controller
|
||||
$phpDefaultPath = $this->resolveBinary('php');
|
||||
$phpDefaultVersion = $phpDefaultPath ? $this->resolvePhpVersion($phpDefaultPath) : null;
|
||||
$phpConfiguredPath = trim((string) Setting::where('key', 'system.php_binary')->value('value'));
|
||||
$phpSelectedPath = $phpConfiguredPath ?: (PHP_BINARY ?: $phpDefaultPath);
|
||||
$phpSelectedOk = (bool) $phpSelectedPath;
|
||||
$phpSelectedVersion = $phpSelectedPath
|
||||
? ($this->resolvePhpVersion($phpSelectedPath) ?? PHP_VERSION)
|
||||
: PHP_VERSION;
|
||||
$phpSelectedPath = null;
|
||||
$phpSelectedVersion = null;
|
||||
$phpSelectedOk = false;
|
||||
|
||||
if ($phpConfiguredPath !== '') {
|
||||
$resolvedConfiguredPhpPath = $this->resolveConfiguredPhpBinaryPath($phpConfiguredPath);
|
||||
$phpSelectedPath = $resolvedConfiguredPhpPath ?: $phpConfiguredPath;
|
||||
$phpSelectedVersion = $resolvedConfiguredPhpPath ? $this->resolvePhpVersion($resolvedConfiguredPhpPath) : null;
|
||||
$phpSelectedOk = $resolvedConfiguredPhpPath !== null && $phpSelectedVersion !== null;
|
||||
} else {
|
||||
$phpSelectedPath = PHP_BINARY ?: $phpDefaultPath;
|
||||
$phpSelectedVersion = $phpSelectedPath
|
||||
? ($this->resolvePhpVersion($phpSelectedPath) ?? $phpDefaultVersion ?? PHP_VERSION)
|
||||
: null;
|
||||
$phpSelectedOk = $phpSelectedPath !== null && $phpSelectedVersion !== null;
|
||||
}
|
||||
$minVersions = $this->resolveMinVersions();
|
||||
$composerPath = $this->resolveBinary('composer');
|
||||
$nodePath = $this->resolveBinary('node');
|
||||
@@ -44,6 +55,8 @@ class SystemStatusController extends Controller
|
||||
|
||||
return response()->json([
|
||||
'php' => PHP_VERSION,
|
||||
'php_web_path' => PHP_BINARY ?: null,
|
||||
'php_web_version' => PHP_VERSION ?: null,
|
||||
'php_default' => $phpDefaultPath,
|
||||
'php_default_version' => $phpDefaultVersion,
|
||||
'php_configured' => $phpConfiguredPath ?: null,
|
||||
@@ -82,7 +95,12 @@ class SystemStatusController extends Controller
|
||||
return false;
|
||||
}
|
||||
|
||||
$resolvedTarget = realpath(dirname($publicStorage) . DIRECTORY_SEPARATOR . $target);
|
||||
$targetPath = $target;
|
||||
if (!str_starts_with($target, DIRECTORY_SEPARATOR) && !preg_match('/^[A-Za-z]:[\\\\\\/]/', $target)) {
|
||||
$targetPath = dirname($publicStorage) . DIRECTORY_SEPARATOR . $target;
|
||||
}
|
||||
|
||||
$resolvedTarget = realpath($targetPath);
|
||||
$expectedTarget = realpath($storagePublic);
|
||||
|
||||
return $resolvedTarget !== false && $expectedTarget !== false && $resolvedTarget === $expectedTarget;
|
||||
@@ -116,6 +134,20 @@ class SystemStatusController extends Controller
|
||||
return $output !== '' ? $output : null;
|
||||
}
|
||||
|
||||
private function resolveConfiguredPhpBinaryPath(string $binary): ?string
|
||||
{
|
||||
$value = trim($binary);
|
||||
if ($value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (str_contains($value, '/')) {
|
||||
return is_executable($value) ? $value : null;
|
||||
}
|
||||
|
||||
return $this->resolveBinary($value);
|
||||
}
|
||||
|
||||
private function resolveBinaryVersion(?string $path, array $args): ?string
|
||||
{
|
||||
if (!$path) {
|
||||
|
||||
Reference in New Issue
Block a user