Weird issue with arguments scope

36 views
Skip to first unread message

@CapedCoder

unread,
May 29, 2012, 4:33:10 PM5/29/12
to framew...@googlegroups.com
I am on CF 10 using the latest version of FW/1 on Windows 2008 R2.  I'm not sure if this is a problem/question with FW/1 or CF10, or my methodology, but here goes.

I have a controller that passes the form scope to the service:
rc.errors = application.beanFactory.getBean('MessageService').saveMessage(form);

My service passes a struct called "data" to my gateway:
function saveMessage(data) {
        return variables.theGateway.saveMessage(data);
    }   

In my gateway I am performing various tasks with "arguments.data", such as:
structKeyExists(arguments.data,'groupid');

The problem I'm running into is that it seems some requests seem to have data from another request mixed in.  For instance a groupid will be present in the arguments.data struct from a request a previous user submitted prior.

Here's the kicker, if I run reload=true all the issues clear up and everything seems to run correctly again for 24 hours or so.

Any ideas on what may be going on?

Thanks!

Seth

Cameron Childress

unread,
May 29, 2012, 4:44:45 PM5/29/12
to framew...@googlegroups.com
On Tue, May 29, 2012 at 4:33 PM, @CapedCoder <cfx...@gmail.com> wrote:
The problem I'm running into is that it seems some requests seem to have data from another request mixed in.  For instance a groupid will be present in the arguments.data struct from a request a previous user submitted prior.

This smells like a perfect candidate for the varScoper:


-Cameron 

--
Cameron Childress
--
p:   678.637.5072
im: cameroncf

Seth Johnson

unread,
May 29, 2012, 5:16:17 PM5/29/12
to framew...@googlegroups.com
I am referring to the fully scoped variable names in my cfc, e.g. arguments.data.groupid, arguments.data.userid

Are you suggesting instead that I copy the variables out of the arguments scope into the local scope and var them?  

I thought the arguments scope was local to the cfc already?

Seth


--
FW/1 on RIAForge: http://fw1.riaforge.org/
 
FW/1 on github: http://github.com/seancorfield/fw1
 
FW/1 on Google Groups: http://groups.google.com/group/framework-one

Seth Johnson

unread,
May 29, 2012, 5:29:51 PM5/29/12
to framew...@googlegroups.com
Cameron,

You were right.  I failed to var scope a query name, that was the issue.

Doh.

Thanks,

Seth

Cameron Childress

unread,
May 29, 2012, 5:31:28 PM5/29/12
to framew...@googlegroups.com
On Tue, May 29, 2012 at 5:29 PM, Seth Johnson <cfx...@gmail.com> wrote:
You were right.  I failed to var scope a query name, that was the issue.

Doh.

Oh man - now I have to go and delete my email explanation about how the problem might not be in the code you showed us....  :)

Glad you got it sorted.

-Cameron
 

Seth Johnson

unread,
May 29, 2012, 5:36:51 PM5/29/12
to framew...@googlegroups.com
Funny the things that sneak into your code at 4:20AM when you are trying to make deadlines...

Much appreciated,

Seth

Nando

unread,
May 30, 2012, 5:37:53 AM5/30/12
to framew...@googlegroups.com
I submitted an enhancement request "Default local scope in variables declared within functions" that would prevent things like this from occurring. "In practice, almost all variables declared in functions are meant to be local, and if they are not, they are explicitly declared using the variables scope for clarity. A helpful enhancement would be to provide a setting where a developer could specify that all variables declared in functions that are not explicitly scoped are placed in the local scope."


If you guys think this might be a good idea, please vote for it to let the CF team know there are others besides me who would appreciate this enhancement.

Nando
--
Nando Breiter

Aria Media
via Rompada 40
6987 Caslano
Switzerland


Nando

unread,
May 30, 2012, 6:11:38 AM5/30/12
to framew...@googlegroups.com
By the way, one of the reasons I personally would like this is because it seems difficult to keep varScoper up to date. As I understand, it currently does not work on script based cfc's and according to what Mike Mike Schierberl has written in his blog, may have difficulty spotting declarations that are not var scoped in the middle of a function which has been possible since the cf9 release. The fact that Mike is asking for help to update the regexes used in varScoper to accomodate script based cfcs, or suggestions on another strategy to use, indicates that we have an unfulfilled need here that may be better met in another way. 


Nando

Sean Corfield

unread,
May 30, 2012, 11:08:10 AM5/30/12
to framew...@googlegroups.com
On Wed, May 30, 2012 at 2:37 AM, Nando <d.n...@gmail.com> wrote:
> I submitted an enhancement request "Default local scope in variables
> declared within functions" that would prevent things like this from
> occurring....
> https://bugbase.adobe.com/index.cfm?event=bug&id=3198706

FWIW, this functionality has been available in Railo for several year
as an option in the admin (Settings > Scope > Local scope mode:
always). You can also control variable lookup cascading across scopes
(which improves performance as well as forcing you to be more explicit
about scoping variables).
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
Reply all
Reply to author
Forward
0 new messages