From 2c1997dcc853d773e19cd886f2f2cf47c7030639 Mon Sep 17 00:00:00 2001 From: Derik Nel Date: Mon, 9 Jan 2017 16:36:22 +0200 Subject: [PATCH 1/5] Updated Allow.php Typecast the $this->_getAllowedCurrencies() to an array so that single string responses don't break the logical checks --- .../Magento/Config/Model/Config/Backend/Currency/Allow.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php index 5ee4a093fb6bf..cc2594af93b56 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php @@ -51,7 +51,7 @@ public function __construct( public function afterSave() { $exceptions = []; - foreach ($this->_getAllowedCurrencies() as $currencyCode) { + foreach ((array)$this->_getAllowedCurrencies() as $currencyCode) { if (!in_array($currencyCode, $this->_getInstalledCurrencies())) { $exceptions[] = __( 'Selected allowed currency "%1" is not available in installed currencies.', @@ -60,7 +60,7 @@ public function afterSave() } } - if (!in_array($this->_getCurrencyDefault(), $this->_getAllowedCurrencies())) { + if (!in_array($this->_getCurrencyDefault(), (array)$this->_getAllowedCurrencies())) { $exceptions[] = __( 'Default display currency "%1" is not available in allowed currencies.', $this->_localeCurrency->getCurrency($this->_getCurrencyDefault())->getName() From cdb1c003842baf21ff69464496e6c2ff2392f71f Mon Sep 17 00:00:00 2001 From: Derik Nel Date: Mon, 9 Jan 2017 16:38:00 +0200 Subject: [PATCH 2/5] Update DefaultCurrency.php Fixed: Something went wrong while saving this configuration: Warning: in_array() expects parameter 2 to be array, string given in /opt/vaimo/deploy/x7642/2017-01-09_13-38-36/htdocs/vendor/magento/module-config/Model/Config/Backend/Currency/DefaultCurrency.php on line 30 --- .../Config/Model/Config/Backend/Currency/DefaultCurrency.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php index 5a5e8f92e568d..f30019a8f016b 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php @@ -27,7 +27,7 @@ public function afterSave() ); } - if (!in_array($this->getValue(), $this->_getAllowedCurrencies())) { + if (!in_array($this->getValue(), (array)$this->_getAllowedCurrencies())) { throw new \Magento\Framework\Exception\LocalizedException( __('Sorry, the default display currency you selected is not available in allowed currencies.') ); From 1727c7e9ebb3e457ebeadc3ca31643b869851f09 Mon Sep 17 00:00:00 2001 From: Derik Nel Date: Tue, 10 Jan 2017 15:26:13 +0200 Subject: [PATCH 3/5] Update Allow.php --- .../Magento/Config/Model/Config/Backend/Currency/Allow.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php index cc2594af93b56..5ee4a093fb6bf 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php @@ -51,7 +51,7 @@ public function __construct( public function afterSave() { $exceptions = []; - foreach ((array)$this->_getAllowedCurrencies() as $currencyCode) { + foreach ($this->_getAllowedCurrencies() as $currencyCode) { if (!in_array($currencyCode, $this->_getInstalledCurrencies())) { $exceptions[] = __( 'Selected allowed currency "%1" is not available in installed currencies.', @@ -60,7 +60,7 @@ public function afterSave() } } - if (!in_array($this->_getCurrencyDefault(), (array)$this->_getAllowedCurrencies())) { + if (!in_array($this->_getCurrencyDefault(), $this->_getAllowedCurrencies())) { $exceptions[] = __( 'Default display currency "%1" is not available in allowed currencies.', $this->_localeCurrency->getCurrency($this->_getCurrencyDefault())->getName() From f2304f203235b40e57c73b8cd51cd94bb7a6ab4c Mon Sep 17 00:00:00 2001 From: Derik Nel Date: Tue, 10 Jan 2017 15:26:37 +0200 Subject: [PATCH 4/5] Update DefaultCurrency.php --- .../Config/Model/Config/Backend/Currency/DefaultCurrency.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php index f30019a8f016b..5a5e8f92e568d 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php @@ -27,7 +27,7 @@ public function afterSave() ); } - if (!in_array($this->getValue(), (array)$this->_getAllowedCurrencies())) { + if (!in_array($this->getValue(), $this->_getAllowedCurrencies())) { throw new \Magento\Framework\Exception\LocalizedException( __('Sorry, the default display currency you selected is not available in allowed currencies.') ); From 7139c7a5ac8dde0b760aed65cbd2bf89e7d18f76 Mon Sep 17 00:00:00 2001 From: Derik Nel Date: Tue, 10 Jan 2017 15:27:04 +0200 Subject: [PATCH 5/5] Update AbstractCurrency.php --- .../Config/Model/Config/Backend/Currency/AbstractCurrency.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php index d8a9d4a00cb88..c3d6348526e33 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php @@ -32,7 +32,8 @@ protected function _getAllowedCurrencies() ) ); } - return $this->getData('groups/options/fields/allow/value'); + + return (array)$this->getData('groups/options/fields/allow/value'); } /**