Saturday, 17 August 2013

CFML: A bit more on getFunctionCalledName(): it's broke in Railo

G'day:
Sorry for the "slow-news week" this week (well: it's been a coupla weeks now). Everything I'm planning to write up will take a while to prep, which means I find excuses to do something else instead.

A while back I wrote about getFunctionCalledName(), mostly because I can never find it in the ColdFusion docs as I never remember enough of what it's called to google it properly. So that article was purely google-bait (it didn't work, just in case you're interested... I still cannot ever remember what getFunctionCalledName() is called, nor can I successfully google it up).


I just came to use it on Railo, to discover it doesn't work. Ooops. It's implemented, but it doesn't do what it says on the tin.

Here's an example:

function callMe(required string actual){
    writeOutput("when calling #actual#(), getFunctionCalledName() returns: #getFunctionCalledName()#<br>");
}

functionRef = callMe;

callMe("callMe");
functionRef("functionRef");

On ColdFusion getFunctionCalledName() works as one would expect:

when calling callMe(), getFunctionCalledName() returns: callMe
when calling functionRef(), getFunctionCalledName() returns: functionRef


However Railo's implementation kinda misses the point:

when calling callMe(), getFunctionCalledName() returns: callMe
when calling functionRef(), getFunctionCalledName() returns: callMe


I haven't raised a bug for this yet as there's already kinda a bug that covers it (RAILO-1670), however I'm not sure whether it's exactly the same, or I need to raise another one. I've mentioned this on their Google Group: "Bug in getFunctionCalledName()".

For the sake of completeness, I tried this on OpenBD, but it is not supported. Just so you know.

That's it. I'll have to approach my Railo code a different way, I guess (the code is not important, just some sample code for another blog article I decided to know out quickly this evening).

--
Adam