tried something which can help out to assign scope...
# cfml-general
g
tried something which can help out to assign scope to the page if the scope does not skip in any scope hopefully someone can enhance it a bit more
Copy code
<cffunction name="findInScopes" returntype="struct">
    <cfargument name="key" type="string" required="yes">
    <cfset var scopeList = ["variables", "cgi", "url", "form", "cookie", "session", "application", "server", "client", "request"]>
    <cfset var foundScopes = {}>

    <cfloop array="#scopeList#" index="currentScope">
        <cfif structKeyExists(evaluate(currentScope), key)>
            <cfset foundScopes[currentScope] = evaluate(currentScope & "." & key)>
        </cfif>
    </cfloop>

    <cfreturn foundScopes>
</cffunction>

<cfset veed = 'red'>
<cfdump var="#findInScopes(veed)#">
m
I'm confused, are you trying to "undo" the implicit scope change that we made specifically to prevent a critical security vector from occurring?
m
I am not sure why you want to do this. ColdFusion has its own scope hierarchy. While it is a bad practice, if you don't specify the scope of a variable, ColdFusion will search for the variable in its own scope hierarchy to find the variable. So, your function is rather meaningless. Even a variable without specifying a scope only works until the next major release (you can add a jvm parameter to not enforce the specifying of a scope right now). So, when the next major version of CF is released, a variable without a scope simply won't work. So, I am not too sure what you are trying to do here.
g
I am not deconstructing it 🤣 Just trying to make the legacy app fixes asap This is just too much work on variables scoping at least with new cf update Which is a major fix
and time consuming a lot of
m
You know you can add a jvm parameter for now, right? This will buy you some time (until the next major release of CF) to actually add the scopes to your variables
âž• 2
m
GSR. I am going to say this as gently as I possibly can. This is not a "fix". You can continue to use the JVM argument in CF23, likely until EOF, which is years away.
You will not be able to update to CF25 until you correctly scope your variables, but you have a long time for that.
g
@Mark Takata (Adobe) if that is the case which means that i can use the JVM argument, then its a great news, I was woriird because usually patches comes after every 2-3 weeks and i do not want myself on a burning chair
you mentioned years i can use the jvm argument, so that is a light of hope Thanks
i will discard my solution, a bad solution 🙂