Saturday 29 September 2012

valueList(): bouquet for OpenBD... play catch-up, ColdFusion & Railo

One of the most curious things about CFML is the valueList() function.  As far as I know, it is the only function in all of CFML for which the argument must be of datatype "Query Column" (please let me know if there are any other examples?).   The Query Column (coldfusion.sql.QueryColumn in CF,  com.naryx.tagfusion.cfm.engine.cfQueryColumnData in OpenBD, and I can't coerce Railo into considering query["column"] a column like I can in CF and OpenBD, so I can't tell you what Railo the Railo class is... Railo just says it's a string), is - unfortunately - not a very well-realised data type in CFML.

Friday 28 September 2012

Thursday 27 September 2012

Survey Results: How ColdFusion updaters should handle CF's version number

I ran a survey a while ago entitled "Which version of ColdFusion am I actually running?", which was in reaction to Adobe not updating the CF10 version number when ColdFusion "10.0.1" 9as they have been referring to it as) was released.  I had observed in bug 3323518 to them that they neglected to update the version number, to which Rupesh responded along the lines of "oh, we did that on purpose, so it's not a bug".  Err... no, Rupesh: just because you did something on purpose does not mean it's not a bug.  For a start, Adobe has well-documented how version numbers are supposed to be handled, and yer not doing it the way your bosses have told you too.  Secondly: to claim that something that is called "10.0.1" should actually have a version number of "10.0.0" is just daft.  Fortunately cooler heads have prevailed - Hemant (scroll down to his comment) and Rakshith's - and they've agreed that this needs fixing.

Wednesday 26 September 2012

Callbacks, function expressions, IIFEs, delegates (OK, and closure I s'pose)

Right, so after a coupla delays, here's the article I threatened you with that's not about closure. Obviously it actually is going to mention closure, but consigned to an afterthought (where, IMO, they kinda belong).

So what is it about? Well it's about a technique that's been possible in ColdFusion since CF5 but is not obvious so is under-utilised, a handy new syntactical construct that was added in CF10, and another one that should have been in CF10 but isn't, something for CF11... and a footnote.

Tuesday 25 September 2012

I RTFM again, and learn something about evaluate() I didn't really know

Here's a quick one: I have 17min before I need to start work.  Tick tock.

The title of this is slightly misleading... I wanted to mention "evaluate()" because it's a controversial function, so the title would garner interest.  Whilst this involves evaluate() tangentially, it's more about a slightly-less-derided function precisionEvaluate().


Monday 24 September 2012

Not what I was intending to do today

I'm back in a cold, wet London after a rather sunny (if quite cool) weekend in Ireland.  And I have a day off work today to recharge my batteries a bit after all the planes, trains & automobiles in the last coupla days.

I was going to write an article "not really about closures" today, but I got sidetracked whilst looking at StackOverflow, and ended up doing something else instead.  It's just a function to convert a number from one arbitrary base to another arbitrary base, and I pinched the algorithm from someone else, but I quite like it so I'm gonna share it here.  And I'll submit it to CFLib too, as  - surprisingly - they do not already seem to have a function to do this.  Weird: I thought everyone has written one of these at some point or another (I know it's about the third time I have written a variation on this theme).

Saturday 22 September 2012

CF on Windows 8 and Java 7

I am sitting in a pub in Portumna, Co. Galway, in Ireland.  Drinking a... [I can't bear to say this]...a Coke.  This is the first time I have been to Ireland and I won't be allowed to have a Guinness. This is a crime against reality.  ("Doctor's orders" in case yer wondering).  I mention this solely because a problem shared is... supposedly... a problem halved. What a load of ballocks.

Anyway, all that is besides the point.

Just in case you weren't hanging on every word on the #ColdFusion tag on Twitter today, I hit Rakshith up about what the story is with two things.

Firstly, I asked for clarification about when CF10 will be installable on Windows 8.  He responded (very quickly, thanks Rakshith!) with a blog article, over here.  The short version is "3-5 months".  Given Windows 8 is due out... what: any day now?... OK, just over a month away according to Wikipedia, that's a bit later than I expected.  That said, it will not affect me one bit (I'm still on Vista on one machine, and only just on Win7 on the other).

The next question was about CF9 and CF10 being certified on Java 7 (Java 6 will be EOLed in Feb next year), and his response (Twitter-only this time) was "support for #ColdFusion on Java 7 will come out before Java 6 gets EOLed in November."

Note: I only just now found out the EOL on Java 6 has been pushed out to Feb 2013 (apparently this will be news to Rakshith too...)

Well I hope it's closer to Nov than Feb, to be honest.  It's one thing for Adobe to get there just under the wire with ColdFusion, but please bear in mind all of use need lab time for our server upgrade testing too.  So having a coupla months leeway would be rather handy.  If Adobe are targeting Nov, then that's cool.

This is a pretty short post (for me), but I'm typing on a dodgy old netbook in a noisy pub (the only place in Portumna I've found with Wifi), so it doesn't lend itself to in depth research.

Time for another pint.  Of Coke.  Sod it.


Friday 21 September 2012

expandPath() weirdness

I had an odd one today.

I was getting some weirdness with this code:

dir            = expandPath(".");
baseDir     = expandPath("/");
relativeDir    = replace(replace(dir, baseDir, ""), "\", "/", "ALL");
cfcPath = replace(relativeDir, "/", ".", "ALL");

Thursday 20 September 2012


So I'm back at work after a week off, and needed to drag myself out of bed a coupla hours earlier than I had become used to, and it's bloody cold today.  So my default setting today is "pissed-off" (so: same as usual, for all intents and purposes).

Wednesday 19 September 2012

But wait...

... there's more.

CFML:Curious behaviour with THIS-scoped variables in onSessionEnd and onApplicationEnd

This article stems from a question that came up on StackOverflow today. In summary the bod wanted to know if they could set this.datasource conditionally on a CGI variable, and I confirmed they could, eg:
  • if the cgi.server_name equals "" => this.datasource = "firstdsn"
  • if the cgi.server_name equals "" => this.datasource = "seconddsn"
My initial response (beyond "just try it and see") was to confirm it was possible.

Someone (called "nosilleg") followed my answer up with  a warning that there could be unexpected results if onSessionEnd (etc) was to use the this.datasource value, as the CGI scope wouldn't be there, so which DSN would be used?  Good question!

To clarify... normal requests all instantiate Application.cfc, and run the pseudo-constructor code to create all the this-scoped config variables, and the CGI variables will all be there so logic predicated on them will work: that's fine.  But things like onSessionEnd() and onApplicationEnd() do not run via a request, per-se, so they won't have any CGI variables.  So what will happen?

This was - of course - my cue to slap together some test code and log stuff and run requests and all that sort of malarky, and now you have to endure reading about my findings.  Well don't say you weren't warned.

So I knocked some code together to test this:

And had a test file to request, thus:

<cfdump var="#this#">

The idea here is that I have DSN1 and DSN2 set up pointing to two different DBs, both of which have identical T_TEST tables to write data to.  Conditional on whether I request test.cfm via localhost or testing.local (both point to the same CF instance) I set this.datasource to point to one or the other (via checking CGI.SERVER_NAME).  If CGI.SERVER_NAME is neither of those, they get nowt.

What I was expecting here was for the onSessionEnd() and onApplicationEnd() to error.  I was not correct.  Well I was a bit correct.  But there is definitely fishy behaviour here.

My log file says this:

Start of logIt(). onApplicationStart [localhost] [dsn1]
End of logIt(). onApplicationStart [localhost] [dsn1]
Start of logIt(). onSessionStart [localhost] [dsn1]
End of logIt(). onSessionStart [localhost] [dsn1]
Start of logIt(). onRequestStart [localhost] [dsn1]
End of logIt(). onRequestStart [localhost] [dsn1]
Start of logIt(). onSessionStart [testing.local] [dsn2]
End of logIt(). onSessionStart [testing.local] [dsn2]
Start of logIt(). onRequestStart [testing.local] [dsn2]
End of logIt(). onRequestStart [testing.local] [dsn2]
Start of logIt(). onRequestStart [localhost] [dsn1]
End of logIt(). onRequestStart [localhost] [dsn1]
Start of logIt(). onSessionEnd [none] [dsn1]
End of logIt(). onSessionEnd [none] [dsn1]
Start of logIt(). onSessionEnd [none] [dsn1]
End of logIt(). onSessionEnd [none] [dsn1]
Start of logIt(). onApplicationEnd [none] [dsn1]
CATCH in logIt(). onApplicationEnd [none] [dsn1] [Attribute validation error for tag CFQUERY.] [The value of the attribute datasource, which is currently '', is invalid.]

I've truncated it, but the "proper" request's log entries were made by "catalina-exec-nn" when nn was a number, whereas the onSessionEnd() and onApplicationEnd() entries were made by "scheduler-n" (where n was a number).  This demonstrates the difference between a normal request running and CF doing its own thing in the background to tidy-up sessions and applications.

Note that neither onSessionEnd() or onApplicationEnd() see a CGI.server_name value.  This is no surprise. However what appears to happen is - by magic, it seems - the onSessionEnd() and onApplicationEnd() calls both receive the last value that this.datasource was set to be via a legit "request".  I verified this through more testing I'll not bore you with, but it was always the DSN of the previous request that these handlers used.  However - rather weirdly - despite onApplicationEnd() definitely seeing this.datasource, the <cfquery> tag in Query.cfc did not think it had a default datasource set.  That's an interesting disconnect, isn't it?  Especially given it seems like onSessionEnd() is in the same boat, but its query worked fine.  Oh, I should have said: data when into the DB tables exactly as one would expect, given the DSN setting (other than the error in onApplicationEnd(), I mean).

If I can be bothered (currently: no) I will refactor the Application.cfc to be tag-based so I can use <cfquery> instead, and see what happens.

Anyway, the bottom line here is that nosilleg was right to be cautious here.  However in situations wherein one doesn't need to use the DSN in the tidy-up handlers, the technique works fine.  I'll feed this back to StackOverflow.

And that's it.


RSS feeds again

I blame Simon for this post ;-)

OK, so I've turned the full feeds back on, but I've made a coupla smaller feeds as well.  Here're the details (also to be found on the right-hand side bar):

The default feed is the one provided by BlogSpot by default, which lists the last n articles (I didn't count how many), and provides the full text.

The other two are provided by Feedburner, and just give the last ten full articles, or the first 500 chars of those articles, respectively.

I hope this covers all the bases for everyone (when I say "everyone" that's bigging-up the half dozen people who read this thing ;-)

I'll have a proper article up at some stage later today.  I meant to write something decent yesterday, but got bogged down on the Railo forums all afternoon, "politely discussing" [cough] some vagaries of Railo I'd found. This was basically the follow-up from that previous article I wrote about the member function methods Railo has for arrays (arrayFindAll(), arrayReverse() (RAILO-2070), and arraySort() (RAILO-2069: already fixed!)), and some back and forth on Railo's <cfdump>.  Inspiring stuff.

But first I need some breakfast (am not working today).



Tuesday 18 September 2012

Bloody RSS feed (and bloody stupid me)

The guys @ CFHOUR pointed out to me that I had my RSS feedback configured incorrectly, in that it was spewing out each entire article instead of just the "above the fold bit".

Monday 17 September 2012

Arrays in Railo (appendix to the earlier 4-part series)

Just when you thought it was safe... here's some more on arrays in ColdFusionRailo. I've already blathered on about the ins and outs of arrays in ColdFusion... well more like arrays in CFML as I cover some stuff in not only ColdFusion but also Railo and a bit on OpenBD too:
But a comment from Gert against one of my blog posts was tucked away in the back of my mind... Railo does some of its own thing when it comes to arrays (and structs, lists, etc).

Friday 14 September 2012

Improving CFML's documentation

I started rambling on in response to a thread on the Railo newsgroup, but after I'd typed about 500 words I thought it was getting a bit long for a forum response, plus it's relevant to more than just Railo anyhow, so I'd centralise it here, and put a summary on the forum and a link back to here.

The gist of the bit of the discussion I was interested in is this bit:

Alan Holden said:
On the documentation front... and this transcends Railo a bit:

I wish there was a "CFML Rosetta Stone". It would be something like CFDocs, but with a matrix architecture so you could quickly x-reference a tag or function across ACF, Railo and OpenBD (& even desktop, cloud, Jakarta, Tomcat versions, etc). This would help us develop apps that worked across the spectrum, help us solve those "it worked here, why not here?" bugs, and thereby help to advance CFML in general - to the benefit of all.

Unfortunately, this will probably remain a wish for some time... for it would probably need to be housed and managed separately, and would take a little chunk of time (and money) to develop and maintain.

Wednesday 12 September 2012

Survey Results: ColdFusion Modularisation

The third survey (there's a first and a second that I have also recently written up) I ran was about how we might think ColdFusion might be modularised: it was to determine how important various areas of ColdFusion are to us, how much we use them, whether we're happy to pay for them or would roll our own or simply do without if they were paid-for options.

I didn't get quite as many answers for this as I did the previous two, which is strange as this one seemed to be the most popular one (going by hits to the page).  Perhaps because there were more options to select on this one, and people couldn't be arsed.  Or having done two surveys already, people got bored.  Oh well (and I completely understand both those positions!).

Anyway, I had to scratch my head for a while as to how to present the data in a useful way, because the questions were large matrices of options, which don't lend themselves well to my fetish-of-the-week: Zingcharts (look at the results of the first two surveys to see what I mean).

Tuesday 11 September 2012

Survey Results: The importance of backwards compat between ColdFusion versions

This survey was all about getting a feel for how people upgrade ColdFusion, and the path they take. And, given that, what there experiences with rework to effect the upgrade was, and how much of an issue it was. And with that in mind: what their thoughts about the weighting Adobe give to this "backwards compatibility at almost any cost" (including, at times, at the expense of common sense).  I discuss the latter notion in a dedicated article.

Monday 10 September 2012

Survey Results: CF strings being interpreted as dates and integers

No articles for a few days, sorry (if indeed I can be so self-indulgent as to think anyone actually gives a toss one way or the other ;-)... I had a busy weekend flitting from London to the other side of Ireland and back in the space of about 40 hours, and have been pretty much shattered as a result.  But here we go now.
I've been running some surveys for a while (see the list of them in the right sidebar), and I've finally got enough results to give some analysis. I decided there was no point in reporting back on a survey unless I got at least 50 results. On a couple of them I'm now well over that, so I'll share the results and editorialise a bit.

Friday 7 September 2012

Wednesday 5 September 2012

Cookies can actually be set after a CFLOCATION...

I seem to have more verbal diarrhoea than usual today.

I was reading a posting on Jason Dean's blog this morning, about being able to set cookies in conjunction with <cflocation>.  Back in the bad old days this wasn't possible because of the way <cflocation> worked, but this has not been the case for some time (which is what Jason is saying in his blog).

One of the comments was asking about whether it was possible to set a cookie after a <cflocation> call, which Jason clarified one could not.  This isn't because of a vagary of cookies and <cflocation>, it's because once a <cflocation> is encountered, ColdFusion stops processing any further code.  It's kinda like a GOTO.

Surveys (update)

Just a very quick one.

Hey, as you know I've been gathering some data for a coupla surveys I've been running, as per the side bar over on the right:

 These two are now closed for new submissions, and the links go to the results "analysis" (or me bleating about them, one of the two):

Well I've finally got sufficient results for the older two (the bottom two on that list) to do some analysis on them.  I've got over 60 responses on both of them. Nice one!  I've also just tipped 50 results on the "Modularisation" one too, so I'll report back on that shortly.  First of all I need to teach myself how Zingcharts work, which is on the menu for this weekend (I won't have a chance between now and then).

Anyway: thanks all.  I'll post the results as soon as I can.


Which version of ColdFusion am I actually running? (follow-up)

G'day: this is a follow-up to yesterday's article in which I asked what was going on with CF's versioning after the recent 10.0.1 updater. The short version is that after the install ColdFusion still reports itself as 10.0, rather than 10.0.1. This is in conflict with:
  • established previous ColdFusion behaviour
  • industry-standard expectations
  • the ColdFusion team's own published material (they refer to it as 10.0.1)
  • Adobe's published Release terminology guidelines
  • common-sense

Tuesday 4 September 2012

SEO Gone Mad (oh, and link bait for the Paralympics)

OK, this is the weirdest one yet.  I was wondering why the hell my blog was so popular today - it's been my biggest day ever so far with a mammoth 600 hits - and I started looking at where the traffic was coming from, because basically unless Ray Camden mentions me on his blog, I don't get much attention.  I promote myself via Twitter and ColdFusionBloggers, but I basically don't exist on the 'net except for that.

Here's the weird thing.  At the moment, if one searches on Bing for "paralympic medal update", this blog ranks first. "paralympics medals": still above the fold @ 6th. Search on Google for "paralympics medal table", and I'm 8th (ie: on the first page).  What?

Which version of ColdFusion am I actually running?

Yet another quick one. I was reading a post on the Adobe ColdFusion forums earlier this morning (I'm sitting on the train en route to work right now), which was discussing the recent ColdFusion "10.0.1" updater.

This raised a question mark for me: what's the new build number for 10.0.1? I like to tuck this info away in the back of my mind, because... err... well no good reason really.

Monday 3 September 2012

Paralympic Medal Table

This is just a quick one.  You'll've noticed I've put a medal table for the Paralympics up over on the right there.  During the Olympics I had a coupla tables there, which I have now retired and posted the final state of the table along with the code, here.

During the Olympics, I was maintaining those tables by hand: I had to run a script, generate the mark-up, edit the blog widget and paste the mark-up in, and update the timestamp.  Tedious.

Now that I have access to a CF server, I've updated the Paralympic table to run automatically.

Search-friendly UI for the Adobe ColdFusion bug tracker

It's one thing having a bleat about how dismal a UX the official ColdFusion bug tracker is, it's another thing to do something about it. I've raised all the shortfalls I've found with Adobe (the bug tracker can be used to raise bugs about itself), but given how slow to react Adobe are to deal with issues with their products that they actually care about, I don't hold out much hope that they'll do any maintenance work on the bug tracker itself.

So, anyway, I've had a complete gutsful of trying to use the thing - I use it a lot in the course of researching stuff for this blog, as well in my day to day work - so I've decided to write my own search UI for it. This was inspired by Elliott Sprehn's efforts to do the same with the old bug tracker.