From 625aa3f1bd144def2529c57b43c8a88212d2346f Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 21 Jan 2021 23:00:34 +0200 Subject: [PATCH 1/3] Fixed a bug in post-install methods --- system/defines.php | 2 +- system/src/Grav/Installer/Install.php | 13 ++++--------- ....7.2_2021-01-21_1.php => 1.7.3_2021-01-21_1.php} | 6 ++++-- 3 files changed, 9 insertions(+), 12 deletions(-) rename system/src/Grav/Installer/updates/{1.7.2_2021-01-21_1.php => 1.7.3_2021-01-21_1.php} (83%) diff --git a/system/defines.php b/system/defines.php index 5b20589d1..612a303a5 100644 --- a/system/defines.php +++ b/system/defines.php @@ -9,7 +9,7 @@ // Some standard defines define('GRAV', true); define('GRAV_VERSION', '1.7.2'); -define('GRAV_SCHEMA', '1.7.2_2021-01-21_1'); +define('GRAV_SCHEMA', '1.7.3_2021-01-21_1'); define('GRAV_TESTING', false); // PHP minimum requirement diff --git a/system/src/Grav/Installer/Install.php b/system/src/Grav/Installer/Install.php index 56696b218..d10427489 100644 --- a/system/src/Grav/Installer/Install.php +++ b/system/src/Grav/Installer/Install.php @@ -218,21 +218,16 @@ ERR; throw new RuntimeException('Grav has already been installed here!', 400); } - // Make sure that none of the Grav\Installer classes have been loaded, otherwise installation may fail! + // Load the installer classes. foreach ($this->classMap as $class_name => $path) { + // Make sure that none of the Grav\Installer classes have been loaded, otherwise installation may fail! if (class_exists($class_name, false)) { throw new RuntimeException(sprintf('Cannot update Grav, class %s has already been loaded!', $class_name), 500); } + + require $path; } - $grav = Grav::instance(); - - /** @var ClassLoader $loader */ - $loader = $grav['loader']; - - // Override Grav\Installer classes by using this version of Grav. - $loader->addClassMap($this->classMap); - $this->legacySupport(); $this->location = dirname($location, 4); diff --git a/system/src/Grav/Installer/updates/1.7.2_2021-01-21_1.php b/system/src/Grav/Installer/updates/1.7.3_2021-01-21_1.php similarity index 83% rename from system/src/Grav/Installer/updates/1.7.2_2021-01-21_1.php rename to system/src/Grav/Installer/updates/1.7.3_2021-01-21_1.php index d10e1bec2..09376f896 100644 --- a/system/src/Grav/Installer/updates/1.7.2_2021-01-21_1.php +++ b/system/src/Grav/Installer/updates/1.7.3_2021-01-21_1.php @@ -17,8 +17,10 @@ return [ try { // Keep old defaults for backwards compatibility. $yaml = YamlUpdater::instance(GRAV_ROOT . '/user/config/system.yaml'); - $yaml->undefine('gpm.releases'); - $yaml->save(); + if (!$yaml->isHandWritten()) { + $yaml->undefine('gpm.releases'); + $yaml->save(); + } } catch (\Exception $e) { throw new InstallException('Could not update system configuration to maintain backwards compatibility', $e); } From 38030c348d95accd152e3a067b2f470e87d8e3be Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 21 Jan 2021 23:45:42 +0200 Subject: [PATCH 2/3] Fixed installer bugs, reverted GPM config post-install hook for now --- system/defines.php | 2 +- .../Grav/Console/Gpm/DirectInstallCommand.php | 3 +- .../Grav/Console/Gpm/SelfupgradeCommand.php | 3 +- system/src/Grav/Console/GravCommand.php | 6 +++- .../Installer/updates/1.7.3_2021-01-21_1.php | 28 ------------------- 5 files changed, 9 insertions(+), 33 deletions(-) delete mode 100644 system/src/Grav/Installer/updates/1.7.3_2021-01-21_1.php diff --git a/system/defines.php b/system/defines.php index 612a303a5..1bc79a711 100644 --- a/system/defines.php +++ b/system/defines.php @@ -9,7 +9,7 @@ // Some standard defines define('GRAV', true); define('GRAV_VERSION', '1.7.2'); -define('GRAV_SCHEMA', '1.7.3_2021-01-21_1'); +define('GRAV_SCHEMA', '1.7.0_2020-11-20_1'); define('GRAV_TESTING', false); // PHP minimum requirement diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php index d551928ff..8712916c0 100644 --- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php +++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php @@ -113,7 +113,6 @@ class DirectInstallCommand extends GpmCommand $io->newLine(); $io->writeln("Preparing to install {$package_file}"); - if (Response::isRemote($package_file)) { $io->write(' |- Downloading package... 0%'); try { @@ -131,7 +130,7 @@ class DirectInstallCommand extends GpmCommand $io->write(' |- Downloading package... 100%'); $io->newLine(); } - } else { + } elseif (is_file($package_file)) { $io->write(' |- Copying package... 0%'); $zip = GPM::copyPackage($package_file, $tmp_zip); if ($zip) { diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index ab9fec713..ac8d4d9b6 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -131,7 +131,8 @@ class SelfupgradeCommand extends GpmCommand $io->writeln("which was released on {$release}"); $config = Grav::instance()['config']; - if ($config->get('versions.core.grav.schema') !== GRAV_SCHEMA) { + $schema = $config->get('versions.core.grav.schema'); + if ($schema !== GRAV_SCHEMA && version_compare($schema, GRAV_SCHEMA, '<')) { $io->newLine(); $io->writeln('However post-install scripts have not been run.'); if (!$this->all_yes) { diff --git a/system/src/Grav/Console/GravCommand.php b/system/src/Grav/Console/GravCommand.php index 41fe61c0d..4634a1fdb 100644 --- a/system/src/Grav/Console/GravCommand.php +++ b/system/src/Grav/Console/GravCommand.php @@ -30,7 +30,11 @@ class GravCommand extends Command { $this->setupConsole($input, $output); - $this->initializeGrav(); + // Old versions of Grav called this command after grav upgrade. + // We need make this command to work with older ConsoleTrait: + if (method_exists($this, 'initializeGrav')) { + $this->initializeGrav(); + } return $this->serve(); } diff --git a/system/src/Grav/Installer/updates/1.7.3_2021-01-21_1.php b/system/src/Grav/Installer/updates/1.7.3_2021-01-21_1.php deleted file mode 100644 index 09376f896..000000000 --- a/system/src/Grav/Installer/updates/1.7.3_2021-01-21_1.php +++ /dev/null @@ -1,28 +0,0 @@ - null, - 'postflight' => - function () { - // Only reset GPM releases value if upgrading from Grav 1.7 RC. - if (version_compare(GRAV_VERSION, '1.7', '<')) { - return; - } - - /** @var VersionUpdate $this */ - try { - // Keep old defaults for backwards compatibility. - $yaml = YamlUpdater::instance(GRAV_ROOT . '/user/config/system.yaml'); - if (!$yaml->isHandWritten()) { - $yaml->undefine('gpm.releases'); - $yaml->save(); - } - } catch (\Exception $e) { - throw new InstallException('Could not update system configuration to maintain backwards compatibility', $e); - } - } -]; From 7c145c7b1e76140c647ec5df0e9eb0b8cf5b2ef1 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 21 Jan 2021 15:19:01 -0700 Subject: [PATCH 3/3] prepare for release --- CHANGELOG.md | 8 +++++++- system/defines.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a980a9221..4196bfc67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# v1.7.2 +# v1.7.3 ## 01/21/2021 1. [](#improved) @@ -12,6 +12,12 @@ * Fixed Clockwork debugger in sub-folder multi-site setups * Fixed `Unsupported option "curl" passed to "Symfony\Component\HttpClient\CurlHttpClient"` in `bin/gpm selfupgrade` [#3165](https://github.com/getgrav/grav/issues/3165) +# v1.7.2 +## 01/21/2021 + +1. [](#improved) + * This release was pulled due to a bug in the installer, 1.7.3 replaces it. + # v1.7.1 ## 01/20/2021 diff --git a/system/defines.php b/system/defines.php index 1bc79a711..8bc03f89b 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.7.2'); +define('GRAV_VERSION', '1.7.3'); define('GRAV_SCHEMA', '1.7.0_2020-11-20_1'); define('GRAV_TESTING', false);