Administrator.cfc does not allow empty default in updateCacheConnection()

Description

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 the updateCacheConnection() to create a cache with an empty default 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 empty default argument to false 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 of false 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.

Environment

Lucee 5.4.6.9

Activity

Show:

Pothys - MitrahSoft 29 August 2024 at 07:22

I have checked and confirmed the issue with the Lucee version 6.1.1.77-BETA. I have made a fix for this issue.
Here’s the PR(6.1): https://github.com/lucee/Lucee/pull/2413

Details

Assignee

Reporter

Priority

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

Flag notifications