ctidigital / magento2-configurator

Magento 2 Configurator
https://ctidigital.github.io/magento2-configurator/
MIT License
169 stars 60 forks source link

Encryption at website scope doesn't work #93

Closed johnhughes1984 closed 4 years ago

johnhughes1984 commented 6 years ago

I will update with a proper overview (and a PR) when I get chance, I'm currently in the midst of creating a local patch, but essentially at website scope the encryption check has been placed above the foreach loop that it needs to reside within. See an example diff below:

diff --git a/Component/Config.php b/Component/Config.php
index 5d2e5c8..631f498 100644
--- a/Component/Config.php
+++ b/Component/Config.php
@@ -93,13 +93,13 @@ class Config extends YamlComponentAbstract

                 if ($scope == "websites") {
                     foreach ($configurations as $code => $websiteConfigurations) {
-                        // Handle encryption parameter
-                        $encryption = 0;
-                        if (isset($configuration['encryption']) && $configuration['encryption'] == 1) {
-                            $encryption = 1;
-                        }
-
                         foreach ($websiteConfigurations as $configuration) {
+                            // Handle encryption parameter
+                            $encryption = 0;
+                            if (isset($configuration['encryption']) && $configuration['encryption'] == 1) {
+                                $encryption = 1;
+                            }
+
                             $convertedConfiguration = $this->convert($configuration);
                             $this->setWebsiteConfig(
                                 $convertedConfiguration['path'],

Essentially $configuration['encryption'] is being checked before it even exists (it doesn't error as the $configuration variable exists from the global scope that runs before).

Thanks for a great open source tool and as noted I'll get a PR sorted when I get a bit of spare time 👍