CF Builder 1: how to add existing project(s) to Navigator
I have a bunch of .cfm pages written and sitting on on remote server: \rem_serv\shared_dir\
See also questions close to this topic
How to improve performance of application?
How can I improve performance of my coldfusion application having many custom tags?
Any procedures or tips to follow?
Undocumented inconsistent behavior regarding ColdFusion's CGI scope/struct
I initially posted this as an answer to this question earlier regarding Empty CGI.REDIRECT_URL on ColdFusion 2016. After thinking about it, I thought better of it since technically didn't answer the OP's question. Instead I decided to make it into a separate question, even though it's more of a commentary than a question. While this technically might not meet the full requirements of a Minimal, Complete, and Verifiable example and people might ding me with downvotes, I decided it was worth it anyway in the hope that it will become easier to find for future CFers who might encounter this. Thus preventing them from banging their head against the wall regarding this peculiar behavior of the CGI struct/scope.
With that said, the CGI struct/scope has some undocumented inconsistent behavior from other structs/scopes. Note that I personally take no credit for this discovery since I happened across this some time ago upon reading Ben Nadel's blog post on this. So all the information I'm posting here is already detailed there, but I wanted to write a nice summary here on SO.
Undocumented behavior 1 - Unlike other structures, if a CGI struct key doesn't exist, then it won't throw an error when referencing it.
In the OP's original question, he was wondering why
cgi.REDIRECT_URLexisted but was empty. As he eventually found out, it never actually existed. As a separate example you can execute this line of code without throwing an error. Not what you'd expect, huh?
So what's a CFer to do? Test for the key existence.
<cfif structKeyExists( CGI, 'THIS_IS_A_FAKE_KEY' )> THIS_IS_A_FAKE_KEY exists <cfelse> THIS_IS_A_FAKE_KEY doesn't exist </cfif>
Undocumented behavior 2 - Unlike other structures, if you dump the CGI struct, it won't display all the key/value pairs, it will only display a defined set of keys.
In the OP's case, he had a custom Apache CGI variable
cgi.REDIRECT_URLthat was used in his code prior to upgrading to CF2016 and was able to refer to it directly. However, I'm presuming if he dumped out the
cgistruct, it wouldn't appear in the dump. In Ben Nadel's case, he also had a custom
cgi.document_rootthat was passed through from a load balancer and was able to refer to it directly, but he also wasn't able to see the key when dumping the
So what's a CFer to do? Understand this and store it in the back of your mind so you won't get bitten when you dump the
cgicontents and the key/value pair isn't there. Other than that, not much else.
CF9: What is this evaluate statement evaluating?
I'm stuck and need a fresh set of eyes on this, please.
I'm working with someone else's spaghetti code who is no longer around and having a heck of a time figuring out what they were evaluating.
<cfset surveyCount = 0> <cfloop query="surveys"> <cfif evaluate("defaultReport" & ID)> <cfset surveyCount = surveyCount + 1> </cfif> </cfloop>
In the query dump, I see 9 records which is what I am expecting but because because the evaluate is failing, the surveyCount isn't being incremented. I do not see any columns for
defaultReport. In my 15 years of working with CF, I've always avoided evaluate() and now when I need to analyze it, I'm at a complete loss. Can someone offer any guidance?
UPDATE I: This file has numerous cfinclude statements and very little code formatting. As a result, I overlooked some cfinclude statements. I found the following. I'm still looking but wanted to document this as I dig.
<cfloop query="surveys"> <cfscript> variables["defaultReport" & ID] = evaluate(thisAssociation & "Price"); </cfscript> </cfloop>