Skip to content

[4.x]: The spread operator still doesn't work correctly in some situations #14827

@MoritzLost

Description

@MoritzLost

What happened?

Description

Follow-up to #14783

I've updated to the latest version, and the spread operator now works correctly in most situations. However, the issue still occurs if the object being spread into another object comes from a method call on an object.

This one is unrelated to the preloadSingles config.

Steps to reproduce

Minimal contrived example:

{% do entry.addError('foo', 'bar') %}
{% do entry.addError('alice', 'bob') %}

{% dd {
    ...entry.getErrors(),
    three: ['four'],
} %}

This should result in a flat array with keys foo, alice and three, but I'm getting a nested array instead:

Screenshot 2024-04-17 at 17 18 13

Not sure if there are still more conditions where the spread operator doesn't work correctly. Might need some exhaustive testing. Maybe check with function calls and filters as well.

Craft CMS version

4.8.9

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions