magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Currency Setup in admin throws in_array error when a single value is selected #8076

Closed deriknel closed 7 years ago

deriknel commented 7 years ago

Preconditions

  1. Magento ver. 2.1.3
  2. Ubuntu 16.04
  3. PHP 7.0.8-0ubuntu0.16.04.3 ( NTS )
  4. MySQL Ver 15.1 Distrib 10.0.28-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Steps to reproduce

  1. In admin navigate to configuration
  2. General -> Currency Setup
  3. Select a single value in the multiple selects
  4. Click on save

Expected result

  1. Currency values should update as per selection

Actual result

  1. Something went wrong while saving this configuration: Warning: in_array() expects parameter 2 to be array, string given in /var/www/clean-m2-ee/vendor/magento/module-config/Model/Config/Backend/Currency/DefaultCurrency.php on line 30

This is because the $this->_getAllowedCurrencies() method returns a string for single values and not an array as expected. Typecasting that to an array would fix this:

if (!in_array($this->getValue(), (array)$this->_getAllowedCurrencies())) {

Or alternatively update the methods to always return arrays.

veloraven commented 7 years ago

@deriknel thank you for your report. I was not able to reproduce this issue. Could you please provide more details?

  1. Full description for currencies setup: for base, default displayed and allowed currencies.
  2. What level of scope do you use?
  3. What Magento mode do you use?
  4. Was it clear install or upgrade from some other version?
deriknel commented 7 years ago

Hi Olga,

  1. Under currency tab, select a single Allowed currency: [image: Inline image 1]

[image: Inline image 2] When selecting a single value, the method $this->_getAllowedCurrencies() returns a string but is used in an in_array logical check in files: Allow.php and DefaultCurrency.php. This is on magento v2.1.3.

  1. Default Config
  2. Magento Developer
  3. Clean Install

Kind Regards, Derik Nel. @: derik.nel@gmail.com

On Thu, Jan 12, 2017 at 2:13 PM, Olga Moyseyenko notifications@github.com wrote:

@deriknel https://github.com/deriknel thank you for your report. I was not able to reproduce this issue. Could you please provide more details?

  1. Full description for currencies setup: for base, default displayed and allowed currencies.
  2. What level of scope do you use?
  3. What Magento mode do you use?
  4. Was it clear install or upgrade from some other version?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/8076#issuecomment-272148568, or mute the thread https://github.com/notifications/unsubscribe-auth/ACITRIJjqM6XKoSa-4zoJwbmZHEH3ypWks5rRhjlgaJpZM4LeTLX .

okorshenko commented 7 years ago

Closing this issue. PR https://github.com/magento/magento2/pull/8077 was delivered to develop branch

magento-team commented 7 years ago

Internal ticket to track issue progress: MAGETWO-65003