From a585439671785ae2321a70d2eee76f912d32bc05 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 16 Jul 2024 09:33:42 +0300 Subject: [PATCH 1/2] logs added to track installation progress --- mollie.php | 8 ++++++++ src/Install/Installer.php | 9 +++++++++ subscription/Install/Installer.php | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/mollie.php b/mollie.php index c68e33c91..203aff5b4 100755 --- a/mollie.php +++ b/mollie.php @@ -155,6 +155,8 @@ private function loadEnv() */ public function install() { + PrestaShopLogger::addLog('Mollie install started', 1, null, 'Mollie', 1); + if (!$this->isPhpVersionCompliant()) { $this->_errors[] = $this->l('You\'re using an outdated PHP version. Upgrade your PHP version to use this module. The Mollie module supports versions PHP 7.2.0 and higher.'); @@ -166,9 +168,11 @@ public function install() return false; } + PrestaShopLogger::addLog('Mollie prestashop install successful', 1, null, 'Mollie', 1); // TODO inject base install and subscription services $coreInstaller = $this->getService(Mollie\Install\Installer::class); + PrestaShopLogger::addLog('Mollie core install initiated', 1, null, 'Mollie', 1); if (!$coreInstaller->install()) { $this->_errors = array_merge($this->_errors, $coreInstaller->getErrors()); @@ -176,6 +180,8 @@ public function install() return false; } + PrestaShopLogger::addLog('Mollie core install successful', 1, null, 'Mollie', 1); + $subscriptionInstaller = new Installer( new DatabaseTableInstaller(), new AttributeInstaller( @@ -187,6 +193,7 @@ public function install() ), new HookInstaller($this) ); + PrestaShopLogger::addLog('Mollie subscription installer initiated', 1, null, 'Mollie', 1); if (!$subscriptionInstaller->install()) { $this->_errors = array_merge($this->_errors, $subscriptionInstaller->getErrors()); @@ -194,6 +201,7 @@ public function install() return false; } + PrestaShopLogger::addLog('Mollie subscription install successful', 1, null, 'Mollie', 1); return true; } diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 60bcc10eb..2560f1359 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -28,6 +28,7 @@ use Mollie\Utility\MultiLangUtility; use OrderState; use PrestaShopException; +use PrestaShopLogger; use Tab; use Tools; use Validate; @@ -96,8 +97,11 @@ public function install() $this->module->registerHook($hook); } + PrestaShopLogger::addLog('Mollie hooks registered successful', 1, null, 'Mollie', 1); + try { $this->orderStateInstaller->install(); + PrestaShopLogger::addLog('Mollie order state install successful', 1, null, 'Mollie', 1); } catch (CouldNotInstallModule $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install Mollie statuses', self::FILE_NAME); @@ -107,6 +111,8 @@ public function install() try { $this->initConfig(); + PrestaShopLogger::addLog('Mollie configurations installed', 1, null, 'Mollie', 1); + } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install config', self::FILE_NAME); @@ -115,6 +121,7 @@ public function install() } try { $this->setDefaultCarrierStatuses(); + PrestaShopLogger::addLog('Mollie default carriers installed', 1, null, 'Mollie', 1); } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install default carrier statuses', self::FILE_NAME); @@ -126,6 +133,7 @@ public function install() try { $this->installVoucherFeatures(); + PrestaShopLogger::addLog('Mollie voucher features installed', 1, null, 'Mollie', 1); } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install voucher attributes', self::FILE_NAME); @@ -134,6 +142,7 @@ public function install() } $this->copyEmailTemplates(); + PrestaShopLogger::addLog('Mollie email templates copied', 1, null, 'Mollie', 1); return $this->databaseTableInstaller->install(); } diff --git a/subscription/Install/Installer.php b/subscription/Install/Installer.php index 6d854ad74..8cfe08d43 100644 --- a/subscription/Install/Installer.php +++ b/subscription/Install/Installer.php @@ -14,6 +14,8 @@ namespace Mollie\Subscription\Install; +use PrestaShopLogger; + if (!defined('_PS_VERSION_')) { exit; } @@ -43,22 +45,31 @@ public function install(): bool { if (!$this->databaseInstaller->install()) { $this->errors = $this->databaseInstaller->getErrors(); + PrestaShopLogger::addLog('Mollie subscription databases install failed', 1, null, 'Mollie', 1); return false; } + PrestaShopLogger::addLog('Mollie subscription databases installed', 1, null, 'Mollie', 1); + if (!$this->attributeInstaller->install()) { $this->errors = $this->attributeInstaller->getErrors(); + PrestaShopLogger::addLog('Mollie subscription attributes install failed', 1, null, 'Mollie', 1); return false; } + PrestaShopLogger::addLog('Mollie subscription attributes install successful', 1, null, 'Mollie', 1); + if (!$this->hookInstaller->install()) { $this->errors = $this->hookInstaller->getErrors(); + PrestaShopLogger::addLog('Mollie subscription hooks install failed', 1, null, 'Mollie', 1); return false; } + PrestaShopLogger::addLog('Mollie subscription hooks install successful', 1, null, 'Mollie', 1); + return true; } } From b5d1c8e1b9779d87cb4cdcb6e6a1a16fdab38ede Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 16 Jul 2024 10:05:22 +0300 Subject: [PATCH 2/2] logs added --- src/Install/Installer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 2560f1359..f8c52300b 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -112,7 +112,6 @@ public function install() try { $this->initConfig(); PrestaShopLogger::addLog('Mollie configurations installed', 1, null, 'Mollie', 1); - } catch (Exception $e) { $errorHandler->handle($e, $e->getCode(), false); $this->errors[] = $this->module->l('Unable to install config', self::FILE_NAME);