Copy link to clipboard
Copied
Base.cfc:
component accessors="true" {
public string function getFilterSql(required array filter) {
... filter["operator"] ?: "" //null-exception
... filter.operator ?: "" //null-exception
... isDefined('filter.operator') ? filter.operator : "" //works
}
Comp.cfc:
component extends="Base" rest="true" produces="application/json" restpath="xyz" {
remote struct function getX() httpMethod="GET" {
var filterSql = getFilterSql(filters);
}
}
When I copy the function from Base.cfc into Comp.cfc ELVIS is working as it is suppose to.
Thank you in advance!
Copy link to clipboard
Copied
It's possible it is failing because your function signature defines "filter" as an array, but you are using filter as a struct in the function body.
Copy link to clipboard
Copied
Thanks for your reply EddieLotter!
"filter" contain an array of structures. As mentioned: When I copy the function from Base.cfc into Comp.cfc it works fine (without changing anyhing).
Copy link to clipboard
Copied
When I copy the function from Base.cfc into Comp.cfc ELVIS is working as it is suppose to.
By @michaels14629018
You cannot yet be sure. The fact that you no longer get an error when you copy the function to Comp.cfc is not proof that things are working as they should. The code does in fact contain errors besides the null exception. Such errors just might be related to the null exception. In any case, it would help clarify the null problem if you first resolved all other issues.
For example,