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:323629
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to