mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-07 12:26:42 +02:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user