PHP 8 Warning in theme_picture()

Created on 8 February 2022, almost 3 years ago
Updated 14 September 2023, over 1 year ago

Problem/Motivation

Using array_map() inside theme_picture() causes the following error in PHP 8:

Warning: drupal_render(): Argument #1 ($elements) must be passed by reference, value given in theme_picture()

See the PHP changelog for array_map():
8.0.0 If callback expects a parameter to be passed by reference, this function will now emit an E_WARNING.

Steps to reproduce

Visit any page with a picture element while running PHP 8.

Proposed resolution

Replace array_map() with a foreach. Using array_walk() would be preferred here, but the array structure cannot be altered which is what drupal_render() does (it changes the array structure to an output string).

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States daniel korte Brooklyn, NY

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024