Hello everyone,
I am currently migrating an application from Lucee 5.4 to Lucee 6. While the step to 6.0.4 was successful, I’ve encountered two significant issues starting from version 6.1.x related to Null handling and how the arguments scope is populated.
#1
In Lucee 5.4 and 6.0, with nullSupport=true, an optional argument defined in a function signature was always present in the arguments scope (as null), even if not passed by the caller. Starting from Lucee 6.1, with nullSupport=true, the key is completely missing from the scope if the argument is not provided.
public void function myFunc( Numeric memberId ) {
// Throws error in 6.1+ if called without args with with nullSupport=true
var resolve = arguments.memberId;
}
myFunc();
Error: The key [MEMBERID] doesn't exist in the arguments scope.
Testing Results:
- 5.4.8.2 / 6.0.4.10: Success (Key exists/is null).
- 6.1.0.243 and above (including 7.0.2.106): Error.
I’ve noticed this behavior is strictly tied to the nullSupport setting:
- With
nullSupport=false, the code works (legacy behavior). - With
nullSupport=true, the key is missing. (I use this)
Question: I can’t tell if this is an intentional change or a bug. I can’t find anything about it in Lucee’s breaking changes. Should I start using safe navigation (?.) for optional parameters?
#2
There is a discrepancy in how null is serialized when nullSupport is disabled.
// Case A: nullSupport=true
cfapplication( action="update", nullSupport=true );
s = { "name": "John", "middleName": null };
echo( serializeJSON( s ) ); // Result: {"name":"John","middleName":null} -> CORRECT
// Case B: nullSupport=false
cfapplication( action="update", nullSupport=false );
s = { "name": "John", "middleName": nullValue() };
echo( serializeJSON( s ) ); // Result: {"name":"John","middleName":null} -> EXPECTED: {"name":"John"}`
According to docs, with nullSupport=false, the key should be omitted from the JSON, as null was not a native type in legacy CFML. This looks like a bug in the new Lucee 6.1+.
Thank you for your support! ![]()
Lucee Version: 6.1.2+47 (CommandBox)