array.append with merge with non array fails silently

Description

Lucee fails silently, ACF still appends the value

https://docs.lucee.org/reference/objects/array/append.html

Merge: This argument only applies when the value is an array.

If set to true appends array elements individually to the source array.

If false (default) the complete array is added as one element at the end, in the source array.

Lucee should either match the ACF behaviour or throw an exception

https://trycf.com/gist/1afad613dbc36a1ef0c06a51c3b59bbb/lucee5?theme=monokai

Activity

Show:
Brad Wood
July 14, 2020, 6:45 AM
Edited

The explanation for this is found here:
https://github.com/lucee/Lucee/blob/5.3/core/src/main/java/lucee/runtime/functions/arrays/ArrayAppend.java#L51
Lucee considers (among other things)

  • empty structs

  • structs with numeric keys

to be castable to an array.

So I disagree that it's strictly 'failing silently'. It's more that Lucee has a more loose sense of what an array is compared to Adobe CF, which I'm sure is important for the BIF to be able to work with native Java collections.

For compatibility, an additional check could be made to ensure that the object was not an explicit struct.

Pothys - MitrahSoft
July 14, 2020, 11:39 PM

Added a test case for this issue.

https://github.com/lucee/Lucee/pull/983

Michael Offner
August 28, 2020, 11:30 PM

i first was considering to only allow struct in case it also has content, but that could lead to even worse missunderstandings of the functionality, so i reduced the flixibility of the cast in that case, Struct are no longer considered as an array in that case.

Michael Offner
August 28, 2020, 11:31 PM

Fixed

Assignee

Unassigned

Reporter

Zac Spitzer

Labels

Sprint

5.3.8 Sprint 3

Fix versions

Affects versions

Priority

New