Skip to content

fix: using null as an array offset is deprecated#5331

Open
sreichel wants to merge 1 commit intoOpenMage:mainfrom
sreichel:fix/null-offset
Open

fix: using null as an array offset is deprecated#5331
sreichel wants to merge 1 commit intoOpenMage:mainfrom
sreichel:fix/null-offset

Conversation

@sreichel
Copy link
Contributor

PHP Deprecated: Using null as an array offset is deprecated, use an empty string instead in

  • app/code/core/Mage/Wishlist/Model/Item.php on line 658
  • app/code/core/Mage/Wishlist/Model/Item.php on line 152
  • app/code/core/Mage/Wishlist/Model/Item.php on line 153

(https://github.com/OpenMage/magento-lts/actions/runs/23358136437/job/67955409410)

PHP Deprecated:  Using null as an array offset is deprecated, use an empty string instead in

- app/code/core/Mage/Wishlist/Model/Item.php on line 658
- app/code/core/Mage/Wishlist/Model/Item.php on line 152
- app/code/core/Mage/Wishlist/Model/Item.php on line 153

(https://github.com/OpenMage/magento-lts/actions/runs/23358136437/job/67955409410)
@sreichel sreichel added the PHP 8.5 Relatee to PHP 8.5 label Mar 20, 2026
Copilot AI review requested due to automatic review settings March 20, 2026 20:54
@github-actions github-actions bot added the Component: Wishlist Relates to Mage_Wishlist label Mar 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses PHP 8.1+ deprecation warnings caused by using null as an array offset in the wishlist item option indexing logic.

Changes:

  • Normalize wishlist item option codes to strings before using them as keys in $_optionsByCode.
  • Normalize getOptionByCode() input to a string to avoid deprecated null array offsets.
  • Update Mage_Wishlist_Model_Item_Option::getCode() PHPDoc to reflect possible null return values.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
app/code/core/Mage/Wishlist/Model/Item/Option.php Adjusts PHPDoc for getCode() to allow null, matching observed usage.
app/code/core/Mage/Wishlist/Model/Item.php Casts option codes to string when indexing/looking up options to prevent deprecated null offsets.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Wishlist Relates to Mage_Wishlist PHP 8.5 Relatee to PHP 8.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants