Skip to content

ArrayIterator incompatible method current() php 7.4 #32088

Closed
@jeroenkosse

Description

@jeroenkosse

Preconditions (*)

  1. Version 2.4.1 and previous releases with support for php 7.4
  2. Environment should use php >= 7.4

Steps to reproduce (*)

  1. Invoke the \Magento\Catalog\Block\Product\ListProduct::initializeProductCollection function on a product page with a product with categories
  2. Following line will be executed: $this->setCategoryId(current($categories->getIterator())->getId());

Expected result (*)

  1. I expect the id from the first category from the product

Actual result (*)

  1. Error is returned because you call getId() on null.
  2. From php >= 7.4 the current() method is no longer returning the first item from a ArrayIterator and instead returns null
  3. More informations about this incompatible change can be found on phpdoc ( https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.spl )

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Component: CatalogComponent: PHP 7.4Fixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: ready for confirmationPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions