A ColdFusion server has been updated to ColdFusion 2018 (from ColdFusion 9 or 11).
One of the oldest applications on that server contains code like: < cfif arguments[key] NEQ "">
Before, this seems to have been equivalent to isDefined("arguments.key")
or StructKeyExists(arguments, key)
.
Today, even though isDefined("arguments.key")
is false, and StructKeyExists(arguments, key)
is also negative, <cfif arguments[key] NEQ "">
fails, because arguments[key] doesn't behave like empty string anymore. In fact, < cfdump var="#arguments[key]#">
displays 'undefined'.
Is there anything I can do in order to avoid changing the code everywhere where empty string was used instead of StructKeyExists
? Perhaps a ColdFusion server parameter? (THIS.enableNullSupport
didn't help)
The bracket notation for the ARGUMENTS
scope will always return an undefined
value for non-existing keys and values in all versions of Adobe ColdFusion.
function f() {
return arguments[key];
}
f(); // returns undefined
function f() {
return arguments["key"];
}
f(); // returns undefined
function f() {
return arguments.key;
}
f(); // throws exception: Element KEY is undefined in ARGUMENTS
All 3 cases should throw an exception. This is inconsistent and should be treated as a bug. It is probably only kept for backwards compatibility.
Anyway, as you already noticed:
// ACF 10
(undefined eq "") -> TRUE
// ACF 11
(undefined eq "") -> TRUE
// ACF 2016
(undefined eq "") -> TRUE
// ACF 2018
(undefined eq "") -> FALSE
// ACF 2021
(undefined eq "") -> TRUE
Adobe introduced NULL support in ACF 2018 and broke this behavior. They fixed it in ACF 2021, but not in ACF 2018, classic Adobe move.
Either report this bug to Adobe and hope for an update (last bugfixing for ACF 2018 was done in November 2019, so good luck) or fix your old application by not relying on this dodgy function argument check.