HELP!!! Is this a bug?

I have come across a very peculiar situation and I can not, for the
life of me, figure it out.
CB 3.5
ACF9.01
ORM
SQL Server 2008

This works...

  //edit(): default action for editing contacts
  public void function edit(required any event, required any rc,
required any prc){
    rc.contact = contactService.new();
    rc.clients = clientService.list(criteria={activeYN=true},
sortOrder="clientName asc", asQuery=false);
    rc.contactTypes =
contactTypeService.findAllWhere(criteria={deactivatedOn=javacast("null","")});
  }

This DOES NOT work...

  //edit(): default action for editing contacts
  public void function edit(required any event, required any rc,
required any prc){
    if(1 == 1){
      rc.contact = contactService.new();
      rc.clients = clientService.list(criteria={activeYN=true},
sortOrder="clientName asc", asQuery=false);
      rc.contactTypes =
contactTypeService.findAllWhere(criteria={deactivatedOn=javacast("null","")});
    }
  }

What I get in my view is that rc.contact is missing...which is stupid
because all I'm adding is an if statement and as we can all clearly
see...that if statement most DEFINITELY resolves to TRUE.

Any thoughts?

I've narrowed it down a little more in that my rc.clients and
rc.contactTypes variables are cancelling out my rc.contact variable.
It has something to do with the functions that are being called to
fill those variables, but I'm not sure what. No matter how I change
up my data call, it still causes rc.contact to be deleted, but
again...only in the context of the if statement. Pull it out of the
if statement and it works as expected.

does it happen in other cf functions like case/switch or do/while?

I’m just curious…


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

Yes, these are problems too, but I’ve narrowed it down to the brackets now. If I don’t have ANY brackets, then everything works. So the brackets of the criteria argument seem to be the cause of the problem. I’m gonna see if moving them out into variables will help, but not sure why the nesting of parens, brackets and braces aren’t taken into account.

Thanks

Erick Wilson
AngelsEye, Inc
800-690-3740 - Ext. 101
800-690-2089 - Fax
ewilson@angelseyeinc.com
www.angelseyeinc.com

“If you don’t know where you are going, any road will take you there.” – Lewis Carroll, Alice in Wonderland

I am guessing this is ACF ?

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Yeah, I’m not sure. I pulled my criteria out and created a variable that consisted of the same data and then put the variable in place of the bracketed criteria and it worked fine. I’m wondering if it’s the way ACF parses the cfscript and what not. Perhaps it doesn’t expect brackets inside a methods argument parens.

Not really sure what is going on there, but I am able to recreate it 100% of the time. I should try it in a “non CB” environment and see if it still does it.

Thanks

Erick Wilson
AngelsEye, Inc
800-690-3740 - Ext. 101
800-690-2089 - Fax
ewilson@angelseyeinc.com
www.angelseyeinc.com

“If you don’t know where you are going, any road will take you there.” – Lewis Carroll, Alice in Wonderland

These are adobe cf issues, i get them too

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

This problem is a very easy problem to understand, and before you do you must be aware of the rules that ColdFusion work by.

The line

if(1=1)

Is not legal, and will not work. This is used for SQL Queries and will always work with SQL queries, but when it comes to ColdFusion it WILL not work at all.

The reason is because the rules of ColdFusion is that any variable name must begin with a letter, underscore, or Unicode currency symbol. This is very clear in all the documentation from Adobe, and I am surprised nobody has picked this up in this case?

Actually that wasn’t the issue in this case as the if(1==1) actually worked as expected when there were no struct brackets in a method argument inside the if statement. Once I added struct brackets inside a method argument (ie. list(criteria={key=value}) as a function call), then the page started doing wacky things.

I need to test it outside of coldbox. I know this kind of syntax works fine in CB on Rail, but this was my first time using Adobe CF 9.01.

Erick Wilson
ewilson@angelseyeinc.com

– Sent from my Galaxy Tablet

I can’t vouch for Railo, but ColdFusion works like this.

variblename operand variable/value

So in your example, it sees the one and tries to reference its value by the variable. Which will not match the value of one so the condition becomes false.

By using the {} will not work either, because these are not meant to be used for conditional statements, and why your are getting further wacky things. Reason because it is no longer conditional, so there is nothing to say yes or no, instead it will be just do.

If that code works in Railo I would be questioning why they allowed this to work, but I don’t know enough about Railo to comment on that.

Either I am confused or you are confused. The “conditional” you keep talking about is the 1 == 1 correct? If so, that has nothing to do with this topic. That was simply a way of forcing the statement to resolve to true and it most definitely works in getting Coldfusion to evaluate to true. I could change it to if(true) and get the same result. The problem lies in using the new notation that Coldfusion has (ie. [] instead of ArrayNew() or {} instead of StructNew()…).

When I do the following…

myMethod(argument1=variable1, argument2={key1=value1,key2=value2}, argument3=“string”);

…then everything works fine, but if I do the following…

if(…some condition that evaluates true…){

myMethod(argument1=variable1, argument2={key1=value1,key2=value2}, argument3=“string”);
}

…then it breaks. I believe this has to do with the fact that there are brackets INSIDE the argument parens when I call “myMethod”. The reason I assess that is because when I change the code to this…

if(…some condition that evaluates true…){
var myStruct = {key1=value1,key2=value2};
myMethod(argument1=variable1, argument2=myStruct, argument3=“string”);
}

…then everything works as expected.
So please let me know if it is me that is confused as to what you are saying. I’ve long since found a workaround to this original issue, but I’d like to know WHY it breaks in this fashion because I have done this type of coding for the last 6 months in Railo and never had a problem. However, can’t seem to get it to work on ACF 9.01.

Thanks

Erick Wilson
AngelsEye, Inc
800-690-3740 - Ext. 101
800-690-2089 - Fax
ewilson@angelseyeinc.com
www.angelseyeinc.com

“If you don’t know where you are going, any road will take you there.” – Lewis Carroll, Alice in Wonderland

Erik,

I think you are getting lost in your own posts, in your very first post the only difference in the code was the if(1==1) condition, and you stated very clearly that the rc.contact would not be defined.

As that is inside the conditional statement, it backs what I was trying to explain to you. When ColdFusion starts to look at 1 == 1 it sees the left hand side and tries to evaluate that, and as 1 is not defined the value will return a 0, and 0 == 1 is a false condition, hence why it will not work and why your variable was always not defined.

I have not focused on any of your other follow up posts, purely because the first one is not written correctly and was the cause of your initial problem.

Hope that clears it up some more for you.

I've had this very same problem in various situations and it seems to
be a bug with CF9.0.1. There were some issues with this in CF9 that
were fixed with 9.0.1 but 9.0.1 introduced some new ones like this.
I've seen it produce some strange issues and solving it involved
moving the struct declaration outside of the arguments supplied to the
method.

I'm not sure that the 'why' you are looking for can be a logical
answer, just that it's broke. Perhaps fixed in the latest hotfixes?

As for 1 == 1, as you know...

if( 1 == 1){
    writeOutput('What is andrew talking about?');
}

...results in 'What is Andrew talking about?' being output.

Andrew, please do not take any ill will from this, I do not mean any, but you are wrong.
Adobe Coldfusion 9.01 WILL evaluate if(1 == 1) as true. I’ve done it. I’m doing it right now. The IF statement is working…the problem isn’t with the if statement.

You focused so much on the one part of the one post (that may have been posted wrong…in your opinion) that you missed the actual point of the post. If you read my whole last message, you will see that I laid out the scenario differently not using variables but using words, so you can plug in ANY expression that would evaluate true. Dominic understood it and he’s at least one other person that has experienced this, so I know I’m not alone.

Since it appears to be a CF bug, I will not inquire about it here anymore, but will be glad to update everyone as soon as I nail down what is going on.

Erick Wilson
AngelsEye, Inc
800-690-3740 - Ext. 101
800-690-2089 - Fax
ewilson@angelseyeinc.com
www.angelseyeinc.com

“If you don’t know where you are going, any road will take you there.” – Lewis Carroll, Alice in Wonderland

Just skimming, but…

if ( 1 == 1)

… is completely valid. It is not comparing a variable; rather it is comparing integers. That said, it is also 100% correct to say that ACF/Railo (and presumably OpenBD) requires that a variable name not begin with a digit. However, that’s not the case with an comparison statement like the one above.

HTH?

So I did a test outside of Coldbox in a standard Adobe Coldfusion 9.01
installation. The problem lies in the structure notation introduced
in CF 8. Not sure it's there in CF 8, but it's there now.

You can copy the below code directly into a .cfm file and run it as is
and you'll see what I'm talking about.
I even created a "variable" I KNOW will evaluate to true and used that
instead of numbers (just to be clear) and the problem still exists.