Coldfusion errors that are suddenly fixed after recompiling the component

190 views Asked by At

We have a coldfusion project on a live server, and the same project on a local development server. Both projects are nearly identical but a few components under development on the dev server. Both servers have the same coldfusion version (cf9).

Suddenly I get a "variable is undefined" error in a component on the live project. This component is exactly the same on the dev project. However the dev project does not throw this error when the exact same code is executed as on the live project.

 private void function updateRecordById(required struct properties) {
    _updateRecord(arguments.properties, aliasFrom(this.name & "_id")&" = "&
    arguments.properties.id);
}

public string function aliasFrom(required string column) {
        var matchingKey = structFindValue(variables.aliases,arguments.column,"ONE");
        return (arraylen(matchingKey)) ? matchingKey[1].key : arguments.column;
    }

The error was "Variable aliasFrom is undefined" (line nr was second line in code sample above). After simply recompiling the component on the live server (by adding writeDump("test");) and restarting the application, the error was fixed.

It looks like the live server compiled updateRecordById(), but didn't compile aliasFrom().

  • What could have caused this error?
  • How can I prevent this from happening again?
  • Why the heck don't I have this error on the dev server in exactly the same code?

more info:

This project uses coldspring to load the components once at applicationStart. The live server has 'cache template in request', 'component cache' and 'save class files' enabled. Simply restarting the application doesn't solve the problem. The component has te be recompiled.

1

There are 1 answers

3
Dale Fraser On BEST ANSWER

It is possible that ColdFusion was serving a cached version of the cfc that wasn't identical. Do you have save compiled componenets enabled on the server?