diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index c52fd5290..7c7a5b63b 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -232,6 +232,29 @@ class SelfupgradeCommand extends GpmCommand $io->writeln("Grav v{$remote} is now available [release date: {$release}]."); $io->writeln('You are currently using v' . GRAV_VERSION . '.'); + // Determine if this is a major/minor version upgrade + $localParts = explode('.', $local); + $remoteParts = explode('.', $remote); + + $localMajor = (int)($localParts[0] ?? 0); + $localMinor = (int)($localParts[1] ?? 0); + $remoteMajor = (int)($remoteParts[0] ?? 0); + $remoteMinor = (int)($remoteParts[1] ?? 0); + + // Check if this is a major/minor version change (e.g., 1.7.x -> 1.8.y) + $isMajorMinorUpgrade = ($localMajor !== $remoteMajor) || ($localMinor !== $remoteMinor); + + if ($isMajorMinorUpgrade) { + $io->newLine(); + $io->writeln('NOTE: This is a major version upgrade.'); + $io->writeln('It is recommended to run `bin/gpm update` first to update all plugins and themes'); + $io->writeln('to their latest compatible versions before upgrading Grav core.'); + } else { + $io->newLine(); + $io->writeln('NOTE: This is a patch version upgrade.'); + $io->writeln('You can safely proceed. Grav will check for any plugin compatibility issues during the upgrade.'); + } + if (!$this->all_yes) { $question = new ConfirmationQuestion( 'Would you like to read the changelog before proceeding? [y|N] ', diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index 143500c08..b7b4e8b8f 100644 --- a/system/src/Grav/Console/Gpm/UpdateCommand.php +++ b/system/src/Grav/Console/Gpm/UpdateCommand.php @@ -117,15 +117,38 @@ class UpdateCommand extends GpmCommand $local = $this->upgrader->getLocalVersion(); $remote = $this->upgrader->getRemoteVersion(); if ($local !== $remote) { - $io->writeln('WARNING: A new version of Grav is available. You should update Grav before updating plugins and themes. If you continue without updating Grav, some plugins or themes may stop working.'); - $io->newLine(); - $question = new ConfirmationQuestion('Continue with the update process? [Y|n] ', true); - $answer = $io->askQuestion($question); + // Determine if this is a major/minor version upgrade by comparing versions + $localParts = explode('.', $local); + $remoteParts = explode('.', $remote); - if (!$answer) { - $io->writeln('Update aborted. Exiting...'); + $localMajor = (int)($localParts[0] ?? 0); + $localMinor = (int)($localParts[1] ?? 0); + $remoteMajor = (int)($remoteParts[0] ?? 0); + $remoteMinor = (int)($remoteParts[1] ?? 0); - return 1; + // Check if this is a major/minor version change (e.g., 1.7.x -> 1.8.y) + $isMajorMinorUpgrade = ($localMajor !== $remoteMajor) || ($localMinor !== $remoteMinor); + + if ($isMajorMinorUpgrade) { + // For major/minor upgrades (e.g., 1.7.x -> 1.8.y), recommend updating plugins FIRST + $io->writeln('WARNING: A new major version of Grav is available (v' . $local . ' -> v' . $remote . ').'); + $io->writeln('For major version upgrades, you should update plugins and themes to their latest compatible versions BEFORE upgrading Grav core.'); + $io->writeln('This ensures plugins have any necessary compatibility fixes for the new Grav version.'); + $io->newLine(); + $io->writeln('It is recommended to proceed with updating plugins and themes now.'); + } else { + // For patch upgrades (e.g., 1.7.45 -> 1.7.46), recommend updating Grav FIRST + $io->writeln('WARNING: A new version of Grav is available (v' . $local . ' -> v' . $remote . ').'); + $io->writeln('You should update Grav before updating plugins and themes. If you continue without updating Grav, some plugins or themes may stop working.'); + $io->newLine(); + $question = new ConfirmationQuestion('Continue with the update process? [Y|n] ', true); + $answer = $io->askQuestion($question); + + if (!$answer) { + $io->writeln('Update aborted. Exiting...'); + + return 1; + } } }