Problem/Motivation

PHP 8 is strict when passing by reference into anonymous functions from array functions.

Steps to reproduce

Proposed resolution

Remove the &

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

N/a

CommentFileSizeAuthor
#2 3173991-2.patch3.36 KBalexpott
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
FileSize
3.36 KB
Gábor Hojtsy’s picture

Do we know why did we pass these by reference in the first place?

andypost’s picture

It looks like micro-optimization all this places using arrays to iterate but iterator is object which always passed by reference in PHP.

Maybe it was written before core started to use objects instead of arrays

I just wondered why sniffers/linters can't catch this yet

andypost’s picture

Issue tags: +PHP 8.0
alexpott’s picture

I think this is a copy and paste error from the original error. There's no optimisation going on. And the reference has no effect.

hussainweb’s picture

Status: Needs review » Reviewed & tested by the community

This is very similar to #3170648: CKEditorPluginManager::getEnabledButtons throws warnings on PHP 8.0.0 beta3 and as shown in the eval there, it is a definite behaviour change in PHP 8.

  • catch committed 0c707fd on 9.1.x
    Issue #3173991 by alexpott, andypost, Gábor Hojtsy, hussainweb:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0c707fd and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

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