Skip to content

Invalid argument supplied for foreach thrown in EAV code  #21134

Closed
@wojtekn

Description

@wojtekn

Preconditions

  1. Latest Magento 2.3

I spot the problem in M2 Commerce in RMA module, but as problem comes from M2 Open Source core and is clearly visible by code review, I'm adding it here.

Steps to reproduce

  1. Enable RMA feature in backend
  2. Place order in frontend
  3. Invoice and ship order in backend
  4. Navigate to order details in My Account pages in frontend
  5. Open order details
  6. Click "Return"

Expected result

RMA form is displayed

Actual result

Exception is thrown:

1 exception(s):
Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in vendor/magento/module-rma/Block/Returns/Create.php on line 155

The problem looks as introduced in \Magento\Eav\Model\Form::getAttributes where not all class variables are initialized as array, but they are returned by method which suppose to return array:

public function getSystemAttributes()
{
    if ($this->_systemAttributes === null) {
        // load attributes
        $this->getAttributes();
    }
    return $this->_systemAttributes;
}

getAttributes method initializes _attributes and _userAttributes variables as arrays but not _systemAttributes and _allowedAttributes.

I will submit PR for this soon.

Metadata

Metadata

Assignees

Labels

Component: EavFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions