PHP 8 Usage of max() with potential string values

Created on 7 November 2023, about 1 year ago
Updated 14 September 2024, 2 months ago

Problem/Motivation

In link.migrate.inc, prepare uses max() to determine $max_delta. This has unintended consequences in PHP 8, as string comparison has changed in the cases where max() compares integer and string values, which can result in a string value like 'target' being used as the $max_delta.

This results in memory exhaustion later in the function where it attempts for ($delta = 0; $delta <= $max_delta; $delta++):
Out of memory (allocated 21563441152) (tried to allocate 42949672960 bytes) in contrib/link/link.migrate.inc on line 124

This is related to πŸ› PHP 8 ValueError: max(): Argument #1 ($value) must contain at least one element in max() in link.migrate.inc Needs review but slightly different.

Steps to reproduce

Migrate link values with extra attributes, e.g. a target attribute or similar.

Proposed resolution

Check $max_delta value uses only integer keys.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024