Problem/Motivation
This is a follow up on a previous iteration: #3164210: Refactor array_merge() usage in loops as possible for performance.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
None
Data model changes
None
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | phpstorm.png | 119.68 KB | mxr576 |
Issue fork drupal-3266568
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
mxr576Comment #4
mxr576Comment #5
mxr576Also addressed the issue was described in #3044373 but was incorrectly fixed.
Comment #6
mxr576Comment #8
yogeshmpawarComment #9
mxr576@yogeshmpawar why needs work? The 9.4.x branch is passing, I assume the 10.x upstream branch is broken somehow, I keep rebasing these MRs, but MR 1892 is ready for review.
Comment #11
quietone commentedThis will be committed to Drupal 10 first, so a MR for D10 is needed before this is ready for review.
Tests were failing on 10 because of Deprecate autovivification on false. Not sure this is the best way to fix it but I thought I would have a go at it.
Comment #14
smustgrave commentedMR 1900 appears to have failures.
Also will have to be updated for 10.1 now please.
Comment #17
sourabhjainComment #18
smustgrave commentedStill failures
Comment #19
mxr576Are these failures are actually related to this change?
Comment #20
mxr576Btw, interdiffs between open MR-s.
1900 and 3385 are basically the same.
Comment #24
mxr576Now 1892 and 3385 are in sync and target branch changed. 3385 can be closed as duplicate.
Comment #25
mxr576hm, when I rolled back @quietone's two changes then these errors have disappeared in my local. Let's see what happens if I commit that change...
Commit ids:
d66f152f88d1590573bd4cc9fa855a1f0f935461
8064cac900af691ce05e3ae0b04527717233845e
Comment #26
mxr576So d66f152f88d1590573bd4cc9fa855a1f0f935461 is needed for sure.
Comment #27
mxr576MR1892 is ready for review \o/
Comment #28
smustgrave commentedLooking at MR 1892
Do we care about other instances? How do you best search for these?
The changes being proposed look good so +1 from me if point above is none issue.
Comment #29
mxr576We can, but I'd probably do this iteratively since this MR already contains several changes.
I'd use a regex like this and audit the surrounding code whether it is a loop or not and what is happening there:
array_merge\([^.]+Comment #30
mxr576Okay so I have added a few more fixes... hopefully they do not cause more work on this MR...
BTW, PHPStorm with Php Inspections (EA Extended) plugin enabled nicely highlights these problems.

Comment #31
smustgrave commentedWill see what the committers say. Fine with doing it in waves but may need a follow up for tracking that.
Comment #33
catchFor scope I think I might have swapped out the array_merge([], ...$foo) when it's already outside a loop to its own issue, so that only the loops need reviewing. But by the time I'd thought of this, I'd already reviewed the patch which looks good. I think it's OK if we don't get all of these, the only way to guarantee not introducing any more would be a phpstan rule (if that's even possible).
Committed 8df6544 and pushed to 10.1.x. Thanks!