Skip to content

Expecting 404, getting 500: "Trying to access array offset on value of type bool" #31984

Closed
@erfanimani

Description

@erfanimani

Preconditions (*)

  1. Magento 2.4.1
  2. PHP 7.4

Steps to reproduce (*)

  1. As an admin, create an saleable product with any URL, such as "box"
  2. Set "Generate "category/product" URL Rewrites" to "No"
  3. As a customer, visit the URL /abc/box.html

Expected result (*)

  1. 404 page not found error, as the category abc does not exist

Actual result (*)

  1. 500, Trying to access array offset on value of type bool on vendor/magento/module-catalog-url-rewrite/Model/Storage/DynamicStorage.php on line 182

PHP 7.4 is become stricter than PHP 7.3 with regards to these types of errors and that's why this bug is showing up it's head now.

https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php#L182

The way the code is written doesn't make sense: the false check is done after an array access is attempted; the false check should be done first.


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: UrlRewriteEvent: Adobe Summit HackathonFixed 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: doneReported on 2.4.1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions