Skip to content

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

Closed
@deriknel

Description

@deriknel

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions