Possible Leaking variables

16 views
Skip to first unread message

Douglas Trojanwoski

unread,
Dec 5, 2013, 12:08:09 PM12/5/13
to model...@googlegroups.com
I never had this problem with fusebox but doesn't mean much since volume that my model-glue app is doing is a bit higher volume.


randomly i get

Element RECORDCOUNT is undefined in rtQUERY

<!---controller--->

               <cfset local.tempObjQueryDAO= {} />
                <cfset local.tempObjQueryDAO= beans.instanceFactory.getBean("QueryDAO") />


                        <cfset rtQUERY= local.tempObjQueryDAO.getQUERY("Value")>
                       
                        <cfif rtQUERY.recordcount>.

                       </cfif>

<!----querydao---->

<cffunction name="getQUERY" >
        <cfargument name="value">
            <cfset rtQuery_Get = {}>
            <cfstoredproc procedure="getQuery_Get" datasource="#getSettings('tmwdsn')#" >
                    <cfprocparam cfsqltype="cf_sql_varchar" value="#arguments.value#">
                    <cfprocresult name="rtQuery_Get"  />
            </cfstoredproc>
            <cfreturn rtQuery_Get >
   
    </cffunction>


I used 'InstanceFactory' help which was given me here when i ran into the problem with queries bleeding over to other users when running the same page

now i stopped getting other users queries return to wrong user but now randomly rtQuery is returning is blank.

my page view has main page and an ajax page imbedded  they both kind of run at the same time both have rtQUERY in there controller function i was wondering if because i don't

var below

<cfset rtQUERY= local.tempObjQueryDAO.getQUERY("Value")>


that rtQuery is bleeding across functions in a controllers?


before i make the be changes does <cfset var keep rtQuery only to that function at the time it is fired and not get sucked in or effect other functions in the controller that run at the same time?

before you ask rtQuery is generic naming for this example.




Dan Wilson

unread,
Dec 5, 2013, 2:41:45 PM12/5/13
to model...@googlegroups.com
Yeah, you are correct. Seems like rtQuery is leaking out under concurrency.

The var keyword will prevent that query from leaking outside of the function scope. Add it in and you'll see the problem go away.

DW




--
--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog
 
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en
---
You received this message because you are subscribed to the Google Groups "model-glue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to model-glue+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Plutarch - "The mind is not a vessel to be filled but a fire to be kindled."

Joe Rinehart

unread,
Dec 5, 2013, 2:56:37 PM12/5/13
to model...@googlegroups.com

does <cfset var keep rtQuery only to that function 


Yes.  You should do this, read about var scoping, and make sure it's entirely understood before continuing any further with CFCs or any CFC-oriented framework such as Model-Glue, FW/1, etc. Otherwise, very confusing errors will intermittently occur.

Douglas Trojanwoski

unread,
Dec 5, 2013, 3:47:30 PM12/5/13
to model...@googlegroups.com
Cool Thank you guys

Jared Rypka-Hauer

unread,
Dec 5, 2013, 4:07:21 PM12/5/13
to model...@googlegroups.com
Very confusing and INCREDIBLY difficult to track down if you don’t know what you’re looking for.
Reply all
Reply to author
Forward
0 new messages