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 #3354440: PHP 8 ValueError: max(): Argument #1 ($value) must contain at least one element in max() in link.migrate.inc 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.

CommentFileSizeAuthor
#2 link-max-string-comparison-3399967-2.patch756 bytestadean

Issue fork link-3399967

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tadean created an issue. See original summary.

tadean’s picture

Assigned: tadean » Unassigned
Status: Active » Needs review
StatusFileSize
new756 bytes

Added potential patch approach for the issue - thanks to @trackleft2 for suggestion.

tibezh’s picture

Status: Needs review » Reviewed & tested by the community

Thanx @tadean, the patch works beautifully!

klausi’s picture

Issue tags: +PHP 8.1

Tagging for PHP 8.1

dqd made their first commit to this issue’s fork.

dqd’s picture

Thanks for the report, patches and efforts in here. +1 I will merge and commit it against 7.x-1.x

  • dqd committed 4a31314c on 7.x-1.x
    Issue #3399967 by dqd, tadean, klausi: PHP 8 Usage of max() with...
dqd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

damienmckenna’s picture