Add compatibility preflight to upgrade flow + compatibility badges

Gpm::upgradeGrav() now calls generatePreflightReport() from the new
package's Install.php before proceeding. If incompatible plugins are
detected, a detailed error message is shown listing which plugins need
to be disabled.

Adds colored compatibility badges (1.7 blue, 1.8 green) to:
- Plugin list, theme list, and plugin detail views
- SCSS badge styles (.gpm-compat-17, .gpm-compat-18, .gpm-compat-api)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andy Miller
2026-04-02 10:26:58 -06:00
parent eb3cc2e9d1
commit 30a90cc69b
5 changed files with 60 additions and 0 deletions

View File

@@ -423,6 +423,25 @@ class Gpm
$script = $folder . '/system/install.php';
/** Install $installer */
if ((file_exists($script) && $install = include $script) && is_callable($install)) {
// Run preflight from the NEW package's installer if available
if (is_object($install) && method_exists($install, 'generatePreflightReport')) {
$report = $install->generatePreflightReport();
$blocking = $report['blocking'] ?? [];
$incompatible = $report['incompatible_packages'] ?? [];
if (!empty($blocking) || !empty($incompatible['blocking'])) {
$errors = [];
foreach ($blocking as $reason) {
$errors[] = $reason;
}
foreach ($incompatible['blocking'] ?? [] as $slug => $info) {
$errors[] = sprintf('<strong>%s</strong> (%s v%s) — not compatible with Grav %s. Disable it to proceed.',
$slug, $info['type'] ?? 'plugin', $info['version'] ?? '?', $incompatible['target'] ?? '?');
}
Installer::setError(implode('<br>', $errors));
return;
}
}
$install($zip);
} else {
Installer::install(