ArrayContains() incompatibility with ACF

Description

<cfscript> numbers = [ 4, 3, 2, 1 ]; writeDump( ArrayContains(numbers, 3) ); </cfscript>

Lucee result : 2
ACF result : true

arrayContains() returns a numeric value, while ACF returns a Boolean value.

Activity

Show:

Zac Spitzer 12 August 2024 at 07:56

I have added a usage note to docs

https://docs.lucee.org/reference/functions/arraycontains.html#usage-notes

it’s cross referenced under our new compat category

https://docs.lucee.org/categories/compat.html

Pothys - MitrahSoft 9 August 2024 at 07:24

Yes, . From my perspective, we need to add a new attribute to resolve the ACF incompatibility issue. Moreover, it won’t affect our current behavior. Most of the ACF-to-Lucee integration users are having a small struggle. I made an improvement to this function that I believe will make it easier to handle. The ArrayFind() function is also working similarly, but ArrayContains() has an additional substringmatch argument.

Brad Wood 8 August 2024 at 16:05

I’m 99% sure this was done this way on purpose. As CF treats positive numbers as truthy, the return is still interchangeable and provides a more specific answer.

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

Priority

Created 8 August 2024 at 14:20
Updated 12 August 2024 at 07:56

Flag notifications