launcher.php: fix PHP 8 fatal in saveManifest
`usort($manifest['versions'] ?? [], ...)` worked in PHP 7 but is a fatal error in PHP 8 — usort requires its first arg by reference and the null-coalesce operator produces an rvalue, not a variable. The existing versions.php didn't trigger it because it sorts $manifest['versions'] directly. Fixed launcher.php to guard with an isset/is_array check and only sort when there's actually a versions array. Triggered by clicking "Définir" in the new Launcher page → 500 page. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,10 @@ function loadManifest(string $path): array
|
||||
|
||||
function saveManifest(string $path, array $manifest): void
|
||||
{
|
||||
usort($manifest['versions'] ?? [], fn($a, $b) => version_compare($b['version'], $a['version']));
|
||||
// usort attend une référence — on ne peut pas lui passer `?? []` en PHP 8.
|
||||
if (isset($manifest['versions']) && is_array($manifest['versions'])) {
|
||||
usort($manifest['versions'], fn($a, $b) => version_compare($b['version'], $a['version']));
|
||||
}
|
||||
file_put_contents(
|
||||
$path,
|
||||
json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"
|
||||
|
||||
Reference in New Issue
Block a user