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.

<cfscript> myarray = ["one","two","three","four","five"]; writeDump(myarray); res = myarray.Append({}, true); writeDump(res); </cfscript>

Lucee should either match the ACF behaviour or throw an exception

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

Attachments

2
  • 13 Jul 2020, 07:17 pm
  • 13 Jul 2020, 06:57 pm

Activity

Show:

Michael Offner 28 August 2020 at 13:30

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.

Pothys - MitrahSoft 14 July 2020 at 13:39

Added a test case for this issue.

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

Brad Wood 13 July 2020 at 20:45
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.

Fixed

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Fix versions

Affects versions

Priority

Created 13 July 2020 at 18:57
Updated 22 March 2025 at 12:44
Resolved 28 August 2020 at 13:32

Flag notifications