It has nothing to do with Application scope and everything to do with poorly written code, sorry to be blunt but that's the issue. As was said all variables you that you want to be local to that method need to be var'ed. Currently you are not doing this so those variables are bleeding out of the method's variable scope (which lives and dies with each call to the method) and getting into the Object's scope (which lives and dies with the application since the Object is stored on the Application scope). Again this is not an issue with putting the object on the Application scope it is an issue with how the variables are defined in the method.
Adam On Thu, Jun 18, 2009 at 8:49 AM, Paul Alkema <[email protected]>wrote: > > Has anyone else experienced this issue before with the application scope? > So > if I ripped this out of the application scope you think it the issue I am > having would be fixed correct? > > Also, please explain what you mean by ensuring that the arguments > parameters > aren't "sticky"? > > Do you mean referencing the scope in the cfargument tag? > > Like... > <cfargument name="arguments.placeholder" type="string" required="yes"> > <cfargument name="arguments.language" type="string" required="yes"> > Instead of... > <cfargument name="placeholder" type="string" required="yes"> > <cfargument name="language" type="string" required="yes"> > > > Thanks! > -----Original Message----- > From: Jason Fisher [mailto:[email protected]] > Sent: Wednesday, June 17, 2009 3:42 PM > To: cf-talk > Subject: RE: Application Scope Problem > > > Completely agree with Brad. Also wouldn't hurt to ensure that the > arguments parameters aren't sticky, by referencing the scope of 'language' > and 'placeholder' as appropriate. > > <cffunction access="public" name="lookup" returntype="string" output="no" > hint="Returns the text found for the given language and placeholder"> > <cfargument name="placeholder" type="string" required="yes"> > <cfargument name="language" type="string" required="yes"> > > <cfset var tempText = ""> > <cfset var getTranslation = "" /> > <cfset var varName = "" /> > > <!--- Attempt to short-circuit the whole translation-in-memory thing, > and just do a lookup TVR 1/19/2008 ---> > > <cfquery name="getTranslation" datasource="mainDNS"> > SELECT content > FROM translations > WHERE lang = <cfqueryparam CFSQLType="STRING" > value="#arguments.language#"> > AND placeholder = <cfqueryparam CFSQLType="STRING" > value="#arguments.placeholder#"> > </cfquery> > > <!--- If nothing found, and not already looking for English, check > English ---> > > <cfif (getTranslation.recordCount EQ 0) AND (arguments.language NEQ > 'EN') > > <cfquery name="getTranslation" datasource="mainDNS"> > SELECT content > FROM translations > WHERE lang = 'EN' > AND placeholder = <cfqueryparam CFSQLType="STRING" > value="#arguments.placeholder#"> > </cfquery> > </cfif> > > <cfif getTranslation.recordCount NEQ 0> > <!--- Replace any variables in the text, marked by <% %>, with > values passed to the function as var1, var2, etc. ---> > <cfset tempText = getTranslation.content> > <cfloop collection="#arguments#" item="varName"> > <cfif ucase(left(varName, 3)) eq "VAR"> > <cfset tempText = replaceNoCase(tempText, "<% #varName#%>", > arguments[varName])> > </cfif> > </cfloop> > </cfif> > > <cfreturn temptext> > </cffunction> > > ---------------------------------------- > From: [email protected] > Sent: Wednesday, June 17, 2009 3:38 PM > To: "cf-talk" <[email protected]> > Subject: RE: Application Scope Problem > > Do you think this could have anything to do with the fact that this > function > is being stored in the application scope? > > ======= > > Yes, it has everything to do with that. You need to var EVERY variable > used in that function. Otherwise it is shared by everyone calling your > code at the exact same time > > getTranslation and varName need to be varred like so at the top of the > function. > > ~Brad > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323725 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

