Posts

ArraySum in Lucee for Query Total and ValueList

Over at Lucess's Atlassian bug board is a reported which I come across all the time in cross compatibility between ACF and Lucee  https://luceeserver.atlassian.net/browse/LDEV-544 I'm not a fan of proprietary functions like queryColumnData, so the easiest equivalent for both to work is : arraysum(listtoarray(valuelist(qryObject.columnname))) Not as neat as the old ArraySum(qryObject["columnname"]), but who cares, I only seem to use it for table totals anyway!

Oh dear, a dodgy old piece of code in ColdFusion 8 style with local scopes!

A seldom used piece of code fell victim to the "new" ColdFusion "Local scope" from CF 9 (Centaur) With an Application.cfc; naturally everything inside it is local'ish when the onRequest exists: <cfcomponent displayname="Application" output="true" hint="Handle the application.">     <cffunction name="OnRequestStart" access="public" returntype="boolean" output="false">         <cfargument name="TargetPage" type="string" required="true"    />         <cfreturn true />     </cffunction>     <cffunction name="OnRequest" access="public" returntype="void" output="true">         <cfargument    name="TargetPage" type="string" required="true" />         <cfinclude template="#arguments.TargetPage#" />         <cfret...

Lucee 4.5.2 cfhttp inconsistent timeout response with Adobe Coldfusion

Trying to catch a timeout is alwas a problem, particularly on those jumpy sites that are normally ok, but can be offline for an hour or 2 when the owners is asleep! There is a bug here https://luceeserver.atlassian.net/browse/LDEV-80 but it is not quite the same and I do get a correct response if in the example below sleep(4000) was replaced by a=1/0; Suppose a file like so: <cfif structkeyexists(url, "test")>     <cfscript>sleep(4000);</cfscript> <cfelse> <cftry>     <cfhttp timeout="2" url="http://#cgi.http_host##cgi.script_name#?test" throwonerror="true" result="x" />     <cfcatch type="any">        <cfdump var="#x#" />         <cfdump var="#cfcatch#" />     </cfcatch> </cftry> </cfif> Lucee 4.5.2 produces Struct errordetail string while the cfcatch adds in this s...

Lucee 4.5.2 cfparam null value error with full null support

With cfparam and the full null support (non default behaviour) there is a dodgy impact: Suppose qryDB has a null valued column, and you set a variable to that null value <cfparam name="myVar" default="#qryDB.nullValueColumn#"> This throws an error, same as would happen in this instance; <cfparam name="myVar"> Though the later appears to be inconsistently present in Adobe ColdFusion also; http://blog.adamcameron.me/2013/04/coldfusion-bugs-id-like-to-see-dealt.html

Lucee 4.5.2 cfpdfparam difference with Adobe ColdFusion

Suppose the following on Lucee 4.5.2: <cfset x = 1> <cfdocument format="pdf" pagetype="A4" name="myVar#x#"> <cfdocumentsection> Hi there </cfdocumentsection> </cfdocument> <cfpdf action="merge" destination="RAM:///myPDF.pdf" overwrite="yes">     <cfpdfparam source="#evaluate("myVar#x#")#" /> </cfpdf> <cfcontent file="RAM:///myPDF.pdf" type="application/pdf"> then to check it also runs on Adobe Cf; you'd actually end up with: "ByteArray objects cannot be converted to strings."   The original code for Adobe CF ran with the paramater like so:  <cfpdfparam source="myVar#x#" /> Both sets of documentation list source defined as follows: "Source PDF file to merge. You can specify a PDF variable, a cfdocument variable, or the pathname to a file." This would indicate it is just...

Global SQL Procedure, System Objects and sp_ms_marksystemobject

You may come across a need to have a database of utils full of generic procedures which work on indvidual databases (say client databases). You can't pass the database name into the procedure as a parameter and say "use @dbname" in the procedure and dynamic sql sucks. One workaround is to create the procedure in the master database and then mark it as a system object. eg use [master] create procedure sp_doThis // note the sp_ prefix is required begin // etc etc end go exec sp_ms_marksystemobject 'sp_doThis' // second note, this procedure is undocumented, so I wouldn't be relying on this for life or death. use [myotherdb] exec sp_doThis go All done!

Design best practice for an image library

If the library holds data in a raw format (ie a big sized image), then can then make all sorts of algorithms out of that to produce images. Generate different sizes, eg 100x100, 200x400 or what ever is required from the original Generate different types of images, either by conversion (png etc) or type, maybe base 64 for CSS and separate style sheet images for non base64 supporting CSS (like IE8 etc) Overlay another graphic on top (like a sash or otherwise) to generate only 1 image that needs to be retrieved All of this requires the smarts that you allow the original image to have coordinates stored against it as to where the center is or maybe use something like  https://github.com/tapmodo/Jcrop to create and store these coordinates of the box sizes. I've found it quite useful when uploading images through custom application to write the files as (for example) full_raw.png (usually stored in a database somewhere) full100x100.png (resized, re scaled depending how ...