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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | link-max-string-comparison-3399967-2.patch | 756 bytes | tadean |
Issue fork link-3399967
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
Comment #2
tadeanAdded potential patch approach for the issue - thanks to @trackleft2 for suggestion.
Comment #3
tibezh commentedThanx @tadean, the patch works beautifully!
Comment #4
klausiTagging for PHP 8.1
Comment #7
dqdThanks for the report, patches and efforts in here. +1 I will merge and commit it against 7.x-1.x
Comment #9
dqdComment #11
damienmckenna