Details
Assignee
Michael OffnerMichael OffnerReporter
dan.switzer@givainc.comdan.switzer@givainc.comPriority
NewNew 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
Affects versions
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
dan.switzer@givainc.com
dan.switzer@givainc.comPriority
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
Affects versions
Created 17 July 2024 at 12:35
Updated 29 August 2024 at 07:22
I’m not entirely sure when this broke, but it’s been recently (it broke between 5.3.10.97 and 5.4.6.9), but the
Administrator.cfc
is breaking when calling theupdateCacheConnection()
to create a cache with an emptydefault
argument:<cfscript> admin = new Administrator("web", LUCEE_WEB_ADMIN_PASSWORD_HERE); admin.updateCacheConnection( "class": "org.lucee.extension.cache.eh.EHCache" , "name": "MyCacheTest" , "bundleName": "" , "bundleVersion": "" , "default": "" , "readonly": false , "storage": false , "custom": { "timeToIdleSeconds": 1800 , "memoryEvictionPolicy": "LRU" , "maxElementsInMemory": 10000 } ); </cfscript>
If you run this, it will throw the following exception:
lucee.runtime.exp.ApplicationException: Invalid default type [ ], valid default types are [object,template,query,resource,function] at lucee.runtime.tag.Admin.toCacheConstant(Admin.java:2771) at lucee.runtime.tag.Admin.doUpdateCacheConnection(Admin.java:2737) at lucee.runtime.tag.Admin._doStartTag(Admin.java:758) at lucee.runtime.tag.Admin.doStartTag(Admin.java:364) at org.lucee.cfml.administrator_cfc$cf.udfCall7(/org/lucee/cfml/Administrator.cfc:1221) at org.lucee.cfml.administrator_cfc$cf.udfCall(/org/lucee/cfml/Administrator.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:358) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:699) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:586) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1952) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1795) at dan.lucee_issues270.adminstrator_cfc_issues1350.updatecacheconnection_empty_default_to_false_cfm5625$cf.call(/test/dan/lucee-issues/Adminstrator-cfc-issues/updateCacheConnection-empty-default-to-false.cfm:19)
In reviewing the the
Administrator.updateCacheConnection
method, you can see it’s translating an emptydefault
argument tofalse
with the following:admin action="updateCacheConnection" type="#variables.type#" password="#variables.password#" class="#arguments.class#" name="#arguments.name#" custom=isNull(arguments.custom) || isEmpty(arguments.custom) ? isEmpty(existing.custom) ? {} : existing.custom : arguments.custom bundleName=isNull(arguments.bundleName) || isEmpty(arguments.bundleName) ? existing.bundleName ?: "" : arguments.bundleName bundleVersion=isNull(arguments.bundleVersion) || isEmpty(arguments.bundleVersion) ? existing.bundleVersion ?: "" : arguments.bundleVersion default=isNull(arguments.default) || isEmpty(arguments.default) ? existing.default ?: false : arguments.default readonly=isNull(arguments.readonly) || isEmpty(arguments.readonly) ? existing.readonly ?: false : arguments.readonly storage=isNull(arguments.storage) || isEmpty(arguments.storage) ? existing.storage ?: false : arguments.storage remoteClients="#variables.remoteClients#"; }
When I look at the
services.cache.create.cfm
source code to see what it’s actually using to create a new cache connection, it does:<cfadmin action="updateCacheConnection" type="#request.adminType#" password="#session["password"&request.adminType]#" name="#trim(form.name)#" class="#trim(form.class)#" bundleName="#isNull(form.bundleName)?"":trim(form.bundleName)#" bundleVersion="#isNull(form.bundleVersion)?"":trim(form.bundleVersion)#" storage="#isDefined('form.storage') and form.storage#" default="#StructKeyExists(form,'default')?form.default:""#" custom="#custom#" remoteClients="#request.getRemoteClients()#">
It does not appear that the
Administrator.cfc
has changed recently, but there was some refactoring of the Admin.java custom tag around the default cache connection code.It would seem that just updating the
Administrator.updateCacheConnection()
so it passes an empty string instead offalse
to the default argument would be the correct course of action.NOTE — There does not appear to be unit test coverage for creating a cache connection for the Administrator.cfc, which is probably why the regression was not caught.