From 646455ac5a4d897973ebaef2da5b1a4debe4dd4b Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Wed, 29 May 2024 01:40:59 +0600 Subject: [PATCH] pkp/pkp-lib#9895 moved app key setup on upgrade as part of migration --- classes/install/Installer.php | 30 ---------- .../v3_5_0/I9895_AddAppKeyToConfigFile.php | 57 +++++++++++++++++++ 2 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 classes/migration/upgrade/v3_5_0/I9895_AddAppKeyToConfigFile.php diff --git a/classes/install/Installer.php b/classes/install/Installer.php index a8303d2b37c..24793938f5a 100644 --- a/classes/install/Installer.php +++ b/classes/install/Installer.php @@ -24,7 +24,6 @@ use PKP\cache\CacheManager; use PKP\config\Config; use PKP\core\Core; -use PKP\core\PKPAppKey; use PKP\core\PKPApplication; use PKP\core\PKPContainer; use PKP\db\DAORegistry; @@ -42,7 +41,6 @@ use PKP\site\VersionDAO; use PKP\xml\PKPXMLParser; use PKP\xml\XMLNode; -use Throwable; class Installer { @@ -1010,34 +1008,6 @@ public function checkPhpVersion() $this->setError(self::INSTALLER_ERROR_GENERAL, 'installer.unsupportedPhpError'); return false; } - - /** - * Add the app key if not already set - * - * @return bool Success/failure - */ - public function addAppKey() - { - // if APP KEY already exists, nothing to do - if (PKPAppKey::hasKey()) { - return true; - } - - // will set an error if app key variable not set - // but will not halt the process - if (!PKPAppKey::hasKeyVariable()) { - error_log("No key variable named `app_key` defined in the `general` section of config file. Please update the config file's general section and add line `app_key = `"); - return true; - } - - try { - PKPAppKey::writeToConfig(PKPAppKey::generate()); - } catch (Throwable $exception) { - error_log($exception->getMessage()); - } finally { - return true; - } - } } if (!PKP_STRICT_MODE) { diff --git a/classes/migration/upgrade/v3_5_0/I9895_AddAppKeyToConfigFile.php b/classes/migration/upgrade/v3_5_0/I9895_AddAppKeyToConfigFile.php new file mode 100644 index 00000000000..72185caf272 --- /dev/null +++ b/classes/migration/upgrade/v3_5_0/I9895_AddAppKeyToConfigFile.php @@ -0,0 +1,57 @@ +getMessage()); + } + } + + /** + * Reverse the downgrades + * + * @throws DowngradeNotSupportedException + */ + public function down(): void + { + throw new DowngradeNotSupportedException(); + } +}