simplified safe-upgrade

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2025-11-10 11:40:01 +00:00
parent 0a1d38a561
commit b568929d02

View File

@@ -708,17 +708,6 @@ class SafeUpgradeManager
Installer::isValidDestination(GRAV_ROOT . '/system'); Installer::isValidDestination(GRAV_ROOT . '/system');
$payload['symlinked'] = Installer::IS_LINK === Installer::lastErrorCode(); $payload['symlinked'] = Installer::IS_LINK === Installer::lastErrorCode();
try {
$safeUpgrade = $this->getSafeUpgradeService();
$payload['preflight'] = $safeUpgrade->preflight();
} catch (RuntimeException $e) {
$payload['safe_upgrade']['staging_ready'] = false;
$payload['safe_upgrade']['error'] = $e->getMessage();
} catch (Throwable $e) {
$payload['safe_upgrade']['staging_ready'] = false;
$payload['safe_upgrade']['error'] = $e->getMessage();
}
return $payload; return $payload;
} }
@@ -797,11 +786,8 @@ class SafeUpgradeManager
return $this->errorResult('Grav installation is symlinked, cannot perform upgrade.'); return $this->errorResult('Grav installation is symlinked, cannot perform upgrade.');
} }
try { // NOTE: We no longer create SafeUpgradeService here because it would load the OLD class.
$safeUpgrade = $this->getSafeUpgradeService(); // Preflight checks are now run in Install.php AFTER downloading, using the NEW code.
} catch (Throwable $e) {
return $this->errorResult($e->getMessage());
}
if (defined('Monolog\\Logger::API') && \Monolog\Logger::API < 3) { if (defined('Monolog\\Logger::API') && \Monolog\Logger::API < 3) {
class_exists(\Monolog\Logger::class); class_exists(\Monolog\Logger::class);
@@ -811,17 +797,9 @@ class SafeUpgradeManager
class_exists(\Monolog\Formatter\LineFormatter::class); class_exists(\Monolog\Formatter\LineFormatter::class);
} }
$preflight = $safeUpgrade->preflight(); // NOTE: Preflight checks are now run in Install.php AFTER downloading the package.
if (!empty($preflight['plugins_pending'])) { // This ensures we use the NEW SafeUpgradeService from the package, not the old one.
return $this->errorResult('Plugins and/or themes require updates before upgrading Grav.', [ // Running preflight here would load the OLD class into memory and prevent the new one from loading.
'plugins_pending' => $preflight['plugins_pending'],
]);
}
$conflictError = $this->handleConflictDecisions($preflight, $decisions);
if ($conflictError !== null) {
return $conflictError;
}
$assets = $this->upgrader->getAssets(); $assets = $this->upgrader->getAssets();
$package = $this->resolveAsset($assets, 'grav-update'); $package = $this->resolveAsset($assets, 'grav-update');
@@ -853,7 +831,7 @@ class SafeUpgradeManager
} }
$this->setProgress('finalizing', 'Finalizing upgrade...', null); $this->setProgress('finalizing', 'Finalizing upgrade...', null);
$safeUpgrade->clearRecoveryFlag(); $this->clearRecoveryFlag();
$this->ensureExecutablePermissions(); $this->ensureExecutablePermissions();
$this->setProgress('finalizing', 'Finalizing upgrade...', null); $this->setProgress('finalizing', 'Finalizing upgrade...', null);
@@ -1230,6 +1208,14 @@ class SafeUpgradeManager
} }
} }
protected function clearRecoveryFlag(): void
{
$flag = GRAV_ROOT . '/user/data/recovery.flag';
if (is_file($flag)) {
@unlink($flag);
}
}
/** /**
* Attempt to run finalize scripts if Grav is already up to date but schema mismatched. * Attempt to run finalize scripts if Grav is already up to date but schema mismatched.
* *