Parts of the ColdFusion Server Scope are read only

Not sure if this is surprising or news to anyone, but this is the first time I’ve run into it so I thought I’d share a blog on it. Yesterday someone on Twitter mentioned that they couldn’t update their ColdFusion server to 9.0.1 without management approval. I got the idea that this would be a monumental task and something occurred to me. What if you updated ColdFusion anyway and used onServerStart to simply change the Server variable containing product version? OK, I’m not advocating we lie to our bosses, but, I had to try it out. This is what I found.

First I tried to change the product version:

<cfdump var="#server#"> <cfset server.coldfusion.productversion = "1">

But that gave me:

Attempted to update or delete a read-only variable.

PRODUCTVERSION is a reserved read-only variable in this scope. The reserved variables in this scope are: "PRODUCTLEVEL", "PRODUCTNAME", "APPSERVER", "PRODUCTVERSION", "EXPIRATION", "INSTALLKIT", "SUPPORTEDLOCALES", "ROOTDIR"

Interesting, right? These are all the default keys you get in the Server scope and I guess Adobe doesn't want you changing them (for good reason probably). Oddly though the server.coldfusion scope can be added to:

<cfset server.coldfusion.coolness = 1>

You get a similar error if you try to change something in the OS scope:

<cfset server.os.arch = "1">

Attempted to update or delete a read-only variable.

ARCH is a reserved read-only variable in this scope. The reserved variables in this scope are: "ARCH","NAME","VERSION","ADDITIONALINFORMATION","BUILDNUMBER"

And you get something similar if you try to mess with coldfusion or os at a higher level:

<cfset server.os = "1">

Attempted to update or delete a read-only variable.

OS is a reserved read-only variable in this scope. The reserved variables in this scope are: "OS","COLDFUSION"

So - all in all - not terribly surprising - but probably good to know.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments