Menu

As simple as possible, as complex as necessary

Migrating from ColdFusion to Railo Part 5: Scope names and local variables

11 December 2014

Continuing my series of notes on the nitty gritty of migrating from ColdFusion 9 to Railo 4.2.

← Migrating from ColdFusion to Railo Part 4: Null and function arguments

Having paddled in the Railo waters in a dev environment for a couple of months now, I feel sufficiently acclimatised to dive in and switch over my first live app from CF9 to Railo.

I'm pleased to report that the custom engine I use to generate this blog is now running on Railo 4.2.2 4.2.1.

Other apps on the same server are still running CF9 since I've installed the BonCode connector for Railo/Tomcat manually, just for the blog engine. This is proving to be a nice way of allowing apps to be migrated one by one.

Apology

Although a generally smooth transition so far, regular readers may have noticed a glitch in the RSS feeds yesterday: the latest items were re-published without links to the posts themselves. Sorry about that.

The cause was a difference in Railo of which I was well aware, but had failed to check for thoroughly.

Issue

In Railo scope names cannot be overwritten, therefore url used on its own is effectively a reserved word. If used as an unscoped local/private variable within functions it will continue to refer to the URL scope.

url.key = "value";

function urlTest(){
  var url = "blog.simplicityweb.co.uk/";
  WriteDump( url );
}

urlTest();

screenshot of url scope dump

The dump outputs the URL scope struct, not the private string variable.

In my RSS feed generation code I'd stupidly used url as an unscoped private variable for each of the item links. Interestingly the RSS generation didn't fail even though it was being given a scope/struct rather than a string, it just ignored that key/element when outputting the XML.

Fix

Use another word. Or if really necessary, include the scope, e.g. local.url or arguments.url.

Migrating from ColdFusion to Railo Part 6: More ORM issues →

Posted on . Updated

Comments

  • Formatting comments: See this list of formatting tags you can use in your comments.
  • Want to paste code? Enclose within <pre><code> tags for syntax higlighting and better formatting and if possible use script. If your code includes "self-closing" tags, such as <cfargument>, you must add an explicit closing tag, otherwise it is likely to be mangled by the Disqus parser.
Back to the top