Skip to main content
Inspiring
August 21, 2008
Answered

Code migration, CF5 to CF8

  • August 21, 2008
  • 1 reply
  • 570 views
I have an application that I'm attempting to migrate from CF5 to CF8, and I'm running into trouble. There are a number of pages constructed like this:

<cfinclude template="first">
Some text, including CF code
<cfinclude template="second">
More text

template 'first' includes a query. Say its name is 'x'. In template 'second', there is

<cfloop query="x">
...

CF8 is returning the following error when this page loads:

Attribute validation error for tag cfloop. The value of the attribute query, which is currently x, is invalid.
The error occurred on line xxx.

CF8's Code Analyzer shows no errors when evaluating this code. But it's as if 'x', which is established in the first cfinclude, isn't passing through to the second cfinclude. Is this a fundamental change from earlier versions of CF?

Thanks in advance for any help.


    This topic has been closed for replies.
    Correct answer User_Since_V1_5
    Issue resolved, and the resolution was very interesting.

    My pages make use of Ben Forta's FakeURL tag, which I'm invoking in application.cfm. This tag makes use of the cgi-scope variable cgi.query_path. It seems that starting with CF7, ColdFusion returns that variable differently than in previous versions:

    Pre-CF7, <mypage.cfm>/param1/param1value/param2/param2value is returned as

    <mypage.cfm>/param1/param1value/param2/param2value

    in cgi.query_path, whereas in CF7 and later, cgi.query_path returns only

    /param1/param1value/param2/param2value

    See

    http://www.webdevref.com/blog/index.cfm?t=CGI.PATH_INFO_Bug_/_Behavior_change_on_CF7&mode=entry&entry=4591F53B-FFDA-3479-C23B8A666B023F6A&dv=link

    for more information.

    This difference was wreaking havoc, in one form or another, on every page. Modifying FakeURL seems to have fixed the issue.

    1 reply

    Inspiring
    August 21, 2008
    There is something else going on in your code. I created a simple test
    case of what you described and it worked fine on my CF8 server. I would
    never do something this ambiguous anymore, but it works.

    We will need to see more code. I suspect something is causing your
    variables to be miss scoped, or otherwise interfered with, do to the
    ambiguity you implied in your description.

    include_test.cfm
    ----------------
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns=" http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Include Test</title>
    </head>

    <body>
    <cfinclude template="include_one.cfm">
    <p> Now we output the query</p>
    <cfinclude template="include_two.cfm">
    </body>
    </html>

    include_one.cfm
    ---------------
    <cfscript>
    x = queryNew('foobar');
    queryAddRow(x,3);
    querySetCell(x,'foobar','one',1);
    querySetCell(x,'foobar','two',2);
    querySetCell(x,'foobar','three',3);
    </cfscript>

    include_two.cfm
    ---------------
    <p>
    <cfoutput query="x">
    #foobar#<br />
    </cfoutput>
    </p>
    Inspiring
    August 21, 2008
    It's very complicated, and if starting from scratch I wouldn't do it this way. But it's worked flawlessly for years. If you look at the (slightly) more complete sample below, showing the page on which everything else is included, you'll see that there are actually two queries in the first include. The first one get 'recognized' just fine; the second throws the error.

    I feel like I'm missing something really basic, but I don't know what it could be.