Problem/Motivation

This module uses array_key_exists() on mixed array/Attribute object in a couple of places.

Using array_key_exists() on objects can be problematic, as described in this core issue: #3090145: Ensure that mixing array and Attribute objects in theme rendering is managed properly.

Also, using array_key_exists() on objects will be deprecated in PHP 8. Visiting /admin/appearance triggers the following deprecation warning:

Deprecated function: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in lazy_preprocess_image() (line 238 of modules\contrib\lazy\lazy.module).
lazy_preprocess_image(Array, 'image', Array) (Line: 287)

Steps to reproduce

If using PHP 7.4, you may be able to trigger the warning by visiting the "Appearance" page at /admin/appearance if a custom theme is available.

Proposed resolution

Use AttributeHelper class. Change record: AttributeHelper is introduced to manage mixed array/Attribute object operations

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Comments

othermachines created an issue. See original summary.

othermachines’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

Patch replaces array_key_exists with AttributeHelper class.

osman’s picture

Component: Documentation » Code
Status: Needs review » Reviewed & tested by the community

I was able to confirm the issue, and the patch works as advertised. Thank you.

  • osman committed 0260dfe on 8.x-3.x authored by othermachines
    Issue #3251508 by othermachines: AttributeHelper class should replace...
osman’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.