Showing posts with label ColdFusion. Show all posts
Showing posts with label ColdFusion. Show all posts

Monday, June 14, 2021

Adobe "Deprecation" - ParameterExists()


5 years ago, I began writing about a function in ColdFusion that was deprecated in ColdFusion MX 6, released 19 years ago. 
ParameterExistsDeprecated Since: ColdFusion MX. Use the IsDefined function.
Back then, we were on ColdFusion 2016, and it still worked. That was almost 14 years and 6 major versions later (2 of which were by a completely different company).



For most of my development career, that one function has been a bit of a running joke and a perfect example of code that sticks around forever. 

We're currently on ColdFusion 2021. Macromedia didn't drop it. Adobe didn't dropped it. Surely they'll have let it go in the last 2 releases, right?



Umm... nope. Still there. 

So, do you think it'll finally go away in the next version? 

If it does, I might cry. That little function has consumed code almost as long as I have. 









Wednesday, November 18, 2020

RECAP: Adobe ColdFusion Summit 2020 - Day 2

 This will continue my mostly stream-of-consciousness review of Day 2 ot ColdFusion Summit 2020 online conference.


DAY 2 (For me at least) 

At 613 AM CST, there are 2412 Total Attendees with 311 now attending. 

Times are still listed as IST, so I have no idea what time what is showing today. Guess I need to do some time zone calcs. :-/


1. Become an Application SUPER-HERO - Reduce the impact of technical debt and keep applications performing as they should -  05:00 PM - 05:50 PM (IST, GMT+5:30) - David Tattersal

I came in well after this one started. This schedule display is really disappointing. Sorry, David, but I'll have to watch the recording of this one. 


Well, I guess this was the "actual" end of Day 1. There's a large break now until the next sessions, so I guess it's time to start my morning here. Coffee and shower. Be back in a bit...


NOTE: Just found https://www.worldtimebuddy.com/. It's showing me a running conversion from IST to CST, so maybe that'll help with scheduling. If nothing else, it easily shows that IST is 11 1/2 hours ahead of me here, so that definitely makes it easier to translate this schedule. A 9PM IST session is a 930AM CST session. Guess I'll be back in a few hours for the actual start of Day 2. 


-----------------------------------------------------------------------------------------


ACTUAL DAY 2 START:

Going into the first "official" session of the day.


1. CSS Crash Course for CSS Haters or Novices - Jessica Keener  @mistersender Twitter/Github


The lower the specificity, the better CSS will work. 

Star Wars illustrations of CSS Specificity Rules is AWESOME!

Doesn't recommend inline style's or !important tag.  NUCLEAR OPTION

CSS => #style vs .style vs style

Semantics - Naming stuff is hard.

Problems with CSS:

- Specificity

- Difficult to locate styles

- Poor context. Where is stuff?

- Difficult to maintain specificity

IT CSS == Inverted Triangle of CSS - @csswizardry (Harry Roberts)

*** BEM method - Block | Element | Modifier - Solves the problems of specificity, context and consistency.

ex card__title--modifier => 

Use Source maps.

GoogleFu: "Flexbox and Grid", "lobotomized owl selecter"


NOTE: Using https://www.mmhmm.app/ for preso. Only available for Mac. But Windows Beta coming soon according to their site. 


Recommended "CSS Secrets: Better Solutions to Everyday Web Design Problems" by Lea Verou



NOTE: As of 10:29 am CST == Total Attendees : 2717 Now Attending : 636


2. Isolation is a Good Thing (For Your Local Development Environments) - Dan Skaggs

This is a talk about using Docker in ColdFusion. 

By default, CF running in a Docker Container, is very isolated (pretty useless). 

- To allow browsing, set up config to talk to webserver inside container. Open/Alias ports. 

    -  This allows access to the Admin panel. 

    - NOTE: In production, you may not want to expose the Admin interface. 

- To serve our code:

    Need to map a folder. CF Docker image, by default, expects to see code inside the image in /app folder. 

- Stop the Docker then map the "volumes" in the docker-compose.yml.

- For CF2021, must install needed packages. 

- When things go wrong..... log files. Must be mapped to an on-disk folder. 


--- I stopped writing notes as Dan talked. More info about setting up databases and data connections. 

I need to learn more about Docker. 


3. Securing ColdFusion Applications - Pete Freitag

I've watched Pete give similar presentations before. They're always full of good information. Pete is a very sharp guy, and any dev will definitely benefit from learning more about security. 


Mature code bases - fun to secure. 


Security often isn't addressed until after a breach. 


First step to securing your old code is to just delete the old code. 


Don't use homemade version control. index_2.cfm is a bad way to version. Version Control is not a fad.


Find obsolete code by looking for files that haven't been modified in the last year. Linux also has the ability to display Last Access of some files. 


Patch your servers. Make sure you're running a supported version of your software. 

Core Support for CF2016 ends Feb 2021!

Also look at OS and Java. 


Follow the Lockdown Guide.


Equifax Breach is a great example of why you should check your software and components. 


Continuous Security ->>> 

  You need version control. 

  Use source inspection security tools. 

  

New functions in CF2021. 

InitSAMLAuthRequest

InitSAMLLogoutRequest

ProcessSAMLResponse


NEVER TRUST A MIME!


Bank of Insecurity is AWESOME!


4. ColdFusion + ReactJS (Round 2): Taking front-end interactivity further - Minh Vo

http://draftstudios.com/demo/

5. Get your Front End Rolling with Vue and InertiaJS - Eric Peterson

These last two sessions dealt with a lot more front-end than I've used. Great info. Both Minh and Eric are very knowledgable educators. These sessions were engaging and 


6. Panel Discussion - Future of ColdFusion

Rakshith Naresh 

Brian Sappey 

Dan Wilson 

Tim Cunningham


The future of ColdFusion definitely lies in The Cloud with more REST functionality. 



After the end of the final Panel:

Total Attendees : 3019

Now Attending : 456


There isn't going to be a closing session, so it looks like it's just ending. 


note from chat:

Charlie Arehart46 sec ago

In case Dan doesn't clarify it, we should note that in CF2021 there is now an alternative to the full gui installer, in the new Express/zip installer. But it doesn't take away from the point he's making about the value of Docker to not even have to "install it" at all, and to be "within Docker" and easily removed/rebuilt/updated via yaml, etc.


==================================================

https://teratech.com/state-of-the-CF-Union-2020-partial-Results


RECAP: Adobe ColdFusion Summit 2020 - Day 1

 This will kick off my "mostly" stream-of-consciousness recap of Day 1 of Adobe's ColdFusion Summit 2020 online conference.

SCHEDULE


Adobe used vcofex.com for the conference. It looks nice. It looks well-organized. The PIP when leaving an Auditorium is pretty cool. It's nice to be able to watch your presentation while still being able to look at the schedule or around the exhibit hall, and especially while being able to access the Help Desk. 

My initial opinion is that this platform is nice, but this event is very poorly put together. The Schedule is confusing: Times are displayed in IST, and since India is almost 12 hours ahead of me, it shows start times for me many hours off. There doesn't seem to be a way to fix this for whatever reason, and initially, the presentations weren't allowing me to join because my time was still way off. It appears that they did something to open up sessions when they go live, but it's still confusing. I did find out that, since it's only two "Auditoriums" running each track, I can just open both up in two different tabs, and then just see when the other starts or stops. 


Day 1

Total Attendees : 1459    Now Attending : 945

1. Keynote:

There were some tech issues. Because of the schedule, I wasn't able to open the Auditorium presentation, so I missed the beginning, and with continued "lagginess" after I was able to open the preso, I also missed large chunks of it. I'll watch the video later. 


2. Managing deployments for your government clients - George Murphy

George talked about how to set up a CI/CD pipeline for an employer who is very locked down and without internet access. This is very applicable to me, since the Army if extremely locked down on what can be run and how we can run it. I'd love to set up some sort of Source Repo and CI/CD for our workgroup. I mostly do database stuff, but I also do some coding and some reporting development. I'd love to be able to get something set up to help keep history of what we have and what we do. 

2b. I switched over to the end of Brian Klaas' talk Building Serverless ColdFusion Applications with cflambda. Brian is always incredibly energetic in his talks and is extremely knowledgeable. I got to have dinner with him last year in Las Vegas at CF Summit 2019, and he was just a great, fun and enjoyable person. And he's very smart. He makes me want to know much more about AWS. 


3.  CFCrimes: Top Ten Issues Migrating to a Modern CF Stack - Mark Takata

Unfortunately had to leave about 10 minutes into this preso. The first few minutes were pretty interesting, so I'll be watching this one on video. 


4. Do It with ColdFusion: Building Your Own Tools with CommandBox - Matthew Clemente

Also missed the first few minutes of this one. His presos are always very informative, and I really want to learn more about CommandBox. So I'll be catching up on this one. So far, some of the CommandBox tools are pretty cool. Print Helper looks very impressive. (Can find what colors your terminal has available). 

There were some tech issues, and Matt's preso ran long. Sucks because it had to be cut off early and I'll have to watch the replay for the end. Otherwise, it was a pretty interesting preso. 

SLIDES HERE


5. This sessions has two presos that I'm very interested in. Charlie Arehart's "Hidden Gems" recaps are always pretty awesome, and I imagine with the recent release of CF 2021, he'll have some good info. But I know that he'll be posting about this and/or presenting this one again, so I may end up watching Dan Wilson talking about modernizing apps with APIs (especially since I can just rewatch these again later).

5a. How to modernize your application with APIs - Dan Wilson

 -- Don't know if this is more tech issues, but it appears that the previous session ran long, and I joined this one several minutes into it. 

One word. "Spaghetti". Dan is reminding me that it's lunch time. 

- Low Encapsulation - Low code reuse. 

 CopyPasteMania (c) :-)

 Taco Based Encapsulation - Medium - Just a little bit of code reuse. 

 Fried Chicken Encapsulation - High - Lots of code reuse. 

 

 He mentioned Adam Tuttle's REST Assured book. I bought this when Adam first wrote it, and he's apparently getting back into more Taffy again. Great stuff.   DISCOUNT CODE: CFSUMMIT


5b. Hidden Gems in Adobe ColdFusion 2021 - Charlie Arehart

 --- See my note on the other session. Scheduling got a little wonky here. 

 Caught the tail end. Lots of monitoring info available. More cool stuff. 

 

NOTE: As of right now, there are 1812 Total Attendees with 830 currently online. It's great to see this many CF Devs interested in CF Summit. 


 6. Have a career, Expert status not required - Dave Ferguson

Dave is always a good speaker, which shouldn't really be surprising considering his background. 

"What is an expert?" Good answers. 

So...... apparently Dave and I have a very similar Geek Origin Story. BASIC, Commodore 64s and MUDs. Best way to start. 


7. Panel Discussion - ColdFusion Application Modernization Challenges

 Kishore Balakrishnan

 Nolan Erck

 Brian Klaas

 Charlie Arehart

 Gavin Pickin

 David Byers

Last session of the day. Good panel discussion of the issues facing CF devs. Lots of good info, especially the recommendations about learning resources.


There are some very interesting sessions happening overnight, but I can't stick around to watch them. I'll catch the videos later. 

......

DAY 2 Coming Next .... 



Tuesday, December 10, 2019

PSA: ColdFusion 2018 Update 7 Released - Security Update

This morning, Adobe released Update 7 for ColdFusion 2018 Server with a Priority 2 Severity Rating (Install Soon [within 30 days]).

It addresses a Privilege Escalation vulnerability on Windows machines: see APSB19-58 and CVE-2019-8256. Non Windows machines are not affected.

The update can be performed automatically through the CF Administrator, or the manual hotfix can be downloaded from HERE.

Adobe also recommends that you update your JDK/JRE to the latest version.

Thursday, January 24, 2019

Adobe ColdFusion and Oracle Java

I have pretty much stayed out of the discussion, because I, frankly, don't currently have much of  a dog in this fight. Oracle threw the ColdFusion world into an uproar with their announcement that they were changing the way Java was licensed. I think it was one of those things where few people really realized how much of an impact it would have until it became a reality on January 1, 2019.

One of the biggest improvements to ColdFusion was it becoming a JVM language. However, that move seems to be creating a lot of confusion. Charlie Arehart has written a ton about Oracle's announcement. As have many other big voices in the CF community.

Earlier today, Adobe announced that they've somewhat come to a resolution for ColdFusion and using Oracle Java. And a big Thank You to Rakshith and the rest of the team for following up with this.

Apparently Java SE 8 and 11 will be supported for Adobe ColdFusion without having to fork over some extra bucks to Oracle. And Adobe is updating both CF2016 and CF2018 to use Java 11 by some time in February 2019. And they seem to be sticking by Oracle.

That does seem to leave CF11 and lower users in a bit of a spot, but I'll be honest. If you're still running ColdFusion 11, you may have more issues than what JVM version you're running. It's probably time to look at some kind of upgrade. I know that ACF can be relatively expensive, but I truly don't understand the belief that CFMX is still a viable system. It may work like it did when written, but

  1. it was released almost 15 years ago, 
  2. there are easily demonstrated Metasploit attacks against it and 
  3. let's not even talk about the OS that it's probably running on. It might be time to move into more modern web development and quit contributing to the belief that CFML is "legacy".


All in all, it may not be a bad idea to move over to Amazon Coretto or OpenJVM or some other non-Oracle JVM. Considering that ColdFusion is pretty tightly coupled with the JVM, I think some sort of JVM will still be pretty necessary for quite a while. I'm not sure of the best option, but I think this definitely put a ginormous plus in the column of switching to a non-Oracle JVM.

I'm not currently managing any CF Servers, but it's probably still time for some intense Google-Fu.




Thursday, October 6, 2016

More Date Masking

I'm a bit ashamed of myself. I've been a member of the ColdFusion Community for over 15 years, yet I just submitted my first bug to the BugBase yesterday. And I'm not even really sure that it's a "bug" per se; just an inconsistency in behavior of similar functions.

https://bugbase.adobe.com/index.cfm?event=bug&id=4194962
(Lucee bug added: https://luceeserver.atlassian.net/browse/LDEV-1025)

Basically, it touches on what has become a pet-peeve of mine: Date Masking. I know I've ranted about it before, but I wish that everyone could just agree on what a proper date mask was for all of the common date parts.

In the latest update to ColdFusion, Update 3, one of the things Adobe announced in the release notes was that you can now use lower- or upper-case letters in DateFormat() masking. My issue with this is that it is completely different behavior from DateTimeFormat(), which seems to make a bit more use of Java's case-sensitive SimpleDateFormat. Granted, I don't agree with Java's way of using "M" to mean "months" and "m" to mean "minutes" (I like CF's "n" minutes), but I still think the two CF functions should be consistent with each other. It's feasible that a dev would have to switch between a date format with and without a time component or have multiple types of date masks on the same page. And the natural assumption would be that the mask from one should work as the mask for the other. At least I would think so.

Last year, I got bit by this behavior when it came to the Year mask. December 29, 2015 was being displayed as 12/29/2016. ???? FYI: DateFormat(someDate,"MM/DD/YYYY") may not return the same thing as DateTimeFormat(someDate,"MM/DD/YYYY"). This is where I learned about the slight difference between a Calendar Year and a Week Year. Not to mention the fact that it will only happen at most on the last few days of a year.

And to make matters worse, we also used moment.js, which expects the year to be formatted as a capital "Y". :-/

I've never made it a secret that I'm not a fan of silent errors. And, yes, this would be an error on the developer's part for not using the proper mask, but it's an easy error to make (especially when using different masks) and even easier to completely miss.

I would like to see Adobe make the date formatting functions be a bit more consistent with each other.


THANK YOU, TRYCF.COM! http://trycf.com/gist/78a374effc62c05330cd33030da265cd/acf2016?theme=monokai

Adobe ColdFusion 2016
Adobe ColdFusion 10

And Lucee just gets wonky with its CFMXish behavior of kinda passing through masks it can't interpret.
Lucee 4.5

Sunday, July 3, 2016

About Application.cfc

Pet Peeve: Proper Capitalization Of Application.cfc --- It's kinda nitpicky, but I hate seeing people write application.cfc/cfm. On a windows machine, it won't hurt. But putting that on a case-sensitive system, like Linux, will quickly teach you the difference between application.cfc and Application.cfc. I'm all for consistency. If you make it a habit to write Application.cfc, even when you don't have to, you won't accidentally mis-name the file when you create it.

That said, this is a topic that has been written about ad nauseam over the years, but it's VERY important to grasp the underlying framework of the Application.cfc file.

https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/application-variables.html

/**
@title "Application.cfc reference in CFScript for Coldfusion 9"
@description "This component includes all Application.cfc methods and variables, set to their default values (if applicable). Please note that default values are not always desirable, and some methods or variables should be modified or removed depending on the situation."
@author "Russ S. (http://cfruss.blogspot.com)"

@dateCreated "November 29, 2009"
@licence "This work is licensed under the Creative Commons Attribution 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA."

@hint "You implement methods in Application.cfc to handle ColdFusion application events and set variables in the CFC to configure application characteristics."
*/


component output="false" {

/* **************************** APPLICATION VARIABLES **************************** */

// The application name. If you do not set this variable, or set it to the empty string, your CFC applies to the unnamed application scope, which is the ColdFusion J2EE servlet context.
THIS.name = "";

// Life span, as a real number of days, of the application, including all Application scope variables.
THIS.applicationTimeout = createTimeSpan(0, 1, 0, 0);

// Whether the application supports Client scope variables.
THIS.clientManagement = false;

// Where Client variables are stored; can be cookie, registry, or the name of a data source.
THIS.clientStorage = "registry"; //cookie||registry||datasource

// Contains ColdFusion custom tag paths.
THIS.customTagPaths = "";

// The Google Maps API key required to embed Google Maps in your web pages.
THIS.googleMapKey = "";

// Name of the data source from which the query retrieves data.
THIS.datasource = "";

// Whether to store login information in the Cookie scope or the Session scope.
THIS.loginStorage = "cookie"; //cookie||session

// A structure that contains ColdFusion mappings. Each element in the structure consists of a key and a value. The logical path is the key and the absolute path is the value.
THIS.mappings = {};

// Whether to enable validation on cfform fields when the form is submitted.
THIS.serverSideFormValidation = true;

// Whether the application supports Session scope variables.
THIS.sessionManagement = true;

// Life span, as a real number of days, of the user session, including all Session variables.
THIS.sessionTimeout = createTimeSpan(0, 0, 30, 0);

// Whether to send CFID and CFTOKEN cookies to the client browser.
THIS.setClientCookies = true;

// Whether to set CFID and CFTOKEN cookies for a domain (not just a host).
THIS.setDomainCookies = false;

// Whether to protect variables from cross-site scripting attacks.
THIS.scriptProtect = false;

// A Boolean value that specifies whether to add a security prefix in front of the value that a ColdFusion function returns in JSON-format in response to a remote call.
THIS.secureJSON = false;

// The security prefix to put in front of the value that a ColdFusion function returns in JSON-format in response to a remote call if the secureJSON setting is true.
THIS.secureJSONPrefix = "";

// A comma-delimited list of names of files. Tells ColdFusion not to call the onMissingTemplate method if the files are not found.
THIS.welcomeFileList = "";

// A struct that contains the following values: server, username, and password.If no value is specified, takes the value in the administrator.
THIS.smtpServersettings = {};

// Request timeout. Overrides the default administrator settings.
THIS.timeout = 30; // seconds

// A list of ip addresses that need debugging.
THIS.debugipaddress = "";

// Overrides the default administrator settings. It does not report compile-time exceptions.
THIS.enablerobustexception = false;

/* ORM variables */

// Specifies whether ORM should be used for the ColdFusion application.Set the value to true to use ORM. The default is false.
THIS.ormenabled = false;

// The struct that defines all the ORM settings. Documentation: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html
THIS.ormsettings = {};

// note: THIS.datasource applies to cfquery as well as ORM. It is defined on line 31.


/* **************************** APPLICATION METHODS **************************** */


/**
@hint "Runs when an application times out or the server is shutting down."
@ApplicationScope "The application scope."
*/
public void function onApplicationEnd(struct ApplicationScope=structNew()) {

return;
}


/**
@hint "Runs when ColdFusion receives the first request for a page in the application."
*/
public boolean function onApplicationStart() {

return true;
}


/**
@hint "Intercepts any HTTP or AMF calls to an application based on CFC request."
@cfcname "Fully qualified dotted path to the CFC."

@method "The name of the method invoked."
@args "The arguments (struct) with which the method is invoked."
*/
public void function onCFCRequest(required string cfcname, required string method, required string args) {

return;
}


/**
@hint "Runs when an uncaught exception occurs in the application."
@Exception "The ColdFusion Exception object. For information on the structure of this object, see the description of the cfcatch variable in the cfcatch description."
@EventName "The name of the event handler that generated the exception. If the error occurs during request processing and you do not implement an onRequest method, EventName is the empty string."

note: This method is commented out because it should only be used in special cases
*/
/*
public void function onError(required any Exception, required string EventName) {
return;
}
*/


/**
@hint "Runs when a request specifies a non-existent CFML page."
@TargetPage "The path from the web root to the requested CFML page."
note: This method is commented out because it should only be used in special cases
*/
/*
public boolean function onMissingTemplate(required string TargetPage) {
return true;
}
*/


/**
@hint "Runs when a request starts, after the onRequestStart event handler. If you implement this method, it must explicitly call the requested page to process it."
@TargetPage "Path from the web root to the requested page."
note: This method is commented out because it should only be used in special cases
*/
/*
public void function onRequest(required string TargetPage) {
return;
}
*/


/**
@hint "Runs at the end of a request, after all other CFML code."

*/
public void function onRequestEnd() {
return;

}


/**
@hint "Runs when a request starts."
@TargetPage "Path from the web root to the requested page."
*/
public boolean function onRequestStart(required string TargetPage) {

return true;
}


/**
@hint "Runs when a session ends."
@SessionScope "The Session scope"

@ApplicationScope "The Application scope"
*/
public void function onSessionEnd(required struct SessionScope, struct ApplicationScope=structNew()) {

return;
}


/**
@hint "Runs when a session starts."
*/
public void function onSessionStart() {

return;
}

}

Tuesday, June 14, 2016

CF_PublicServiceAnnouncement: Updates Galore!

First off, Adobe has released new patches for the ColdFusion products.This includes a Security Hotfix for CF2016, 11 and 10 for a potential XSS issue, so it would probably be a good idea to update.

http://blogs.coldfusion.com/post.cfm/updates-for-coldfusion-2016-coldfusion-builder-2016-coldfusion-11-and-coldfusion-10-released

Also today, Lucee 4.5.3 has been released with a heap of fixes.

http://lucee.org/blog/lucee-4-5-3-release.html


Wednesday, June 8, 2016

ColdFusion Scopes: Part Deux - "Mutually Exclusive" LOCAL and ARGUMENTS

While playing with LOCAL and ARGUMENTS scopes and the scope order bug, I also came across a behavior that I didn't really know about - LOCAL and ARGUMENTS scopes in a CF function are supposed to be "mutually exclusive". Maybe I misunderstand what that phrase means.

https://gist.github.com/shawnoden/ef494ef92ccd3821a189 http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec09af4-7ff1.html http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a66e-7fe2.html http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec09af4-7fdf.html

Monday, April 25, 2016

Adobe ColdFusion Developer Week 2016

For those of you who haven't heard yet:

http://blogs.coldfusion.com/post.cfm/adobe-coldfusion-developer-week-2016-april-24-29

Adobe Developer Week is currently going on. Two sessions per day. Good info. David Epler's Security Enhancements in ColdFusion 2016 is about to start. 

For the other sessions (from Adobe): 


Monday, April 25, 2016
9:00 - 10:00 am
ColdFusion 2016 Overview
12:00 - 1:00 pm
Security Enhancements in ColdFusion 2016
Tuesday, April 26, 2016
9:00 - 10:00 am
Mobile Applications Made Easy with ColdFusion
12:00 - 1:00 pm
Exploring PDF Capabilities in ColdFusion
Wednesday, April 27, 2016
9:00 - 10:00 am
Protecting APIs using CF 2016 API Manager
12:00 - 1:00 pm
MVC With and Without a Framework
Thursday, April 28, 2016
9:00 - 10:00 am
Realtime with WebSockets
12:00 - 1:00 pm
ColdFusion Performance Tuning and Caching
Friday, April 29, 2016
9:00 - 10:00 am
Extending PDF capabilities using DDX
12:00 - 1:00 pm
CFML Features for More Modern Coding
Follow their link and sign up.

Monday, February 29, 2016

Date Masking Inconsistency

What better way to celebrate Leap Day than with a Date Masking post? It's been cooking in my noggin a while and has been in some form of draft for a month, but better late than never, right? :-/

TL;DR: ALWAYS VERIFY YOUR DATE MASKS ARE DOING WHAT YOU THINK THEY'RE DOING!

I originally encountered this at the beginning of February and while digging for the cause, came across the issue in the CFDocs site (https://github.com/foundeo/cfdocs/issues/266). I played a bit with some of the masking and learned that some of my old ways were smacking me. I've been in the habit of masking a DateTime object with "MM/DD/YYYY..." or something like that. I absolutely hate date math and manipulation, but that hatred has led me to learning more than I ever wanted to know about the bazillion different epoch times and how 12:59:59.998 can sometimes be the same as 00:00:00.000. There's a bit of a rabbit hole there, and I've fallen down it more than I care for.

But I digress. The CFDocs site referenced an Adobe bug for CF10 (https://bugbase.adobe.com/index.cfm?event=bug&id=4105828) reported by Alexander Kwaschny, and as I was playing with this, I began to realize how big of an issue this actually could be for us. FORTUNATELY I didn't find anywhere in our code where we were using dateTimeFormat(), just dateFormat(), but we _were_ using the "YYYY" mask. I'm a firm believer in consistency (that may be a holdover from my piloting days), and I think that if you're going to do something, you should always try to do it the same way to minimize the opportunity for error. Date Masking is a big area that has a lot of potential to cause hard-to-detect problems, and we were setting ourselves up for a big one here. Though I can't really fault anyone, since pretty much every example of date masking or formatting that I've ever seen uses capital letters. I think it's insane for a language (THANKS JAVA, and maybe even ISO8601) to treat "Y" and "y" as two different things for such a narrow edge case. Until this issue, I had never even heard of a Week Year ("Y") (https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html). And to make the issue more fun, it would only even come into play at most about 6 days out of an entire year. You probably wouldn't even notice the problem.

So, my solution.... make sure my date masks reflect the proper things in the languages that I'm using. My years now are formatted with "yyyy" instead of "YYYY", though most of the time, it doesn't make a difference either way. Grrrr.....

======= MY RESEARCH ========
First, I wanted to verify that Oracle is documented to behave as I expect it to. https://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements004.htm#CDEHIFJA Oracle 11g Datetime Format Elements

Yup, Oracle treats "Y" and "y" as the same thing in its formatting. Note: even the Oracle examples show "Y" for the date mask.

One other cool thing I discovered about Oracle... the capitalization of the Month mask will determine the capitalization of the output.
'' Months : To_Char(myDate,'MONTH') AS CAPDATE, To_Char(myDate,'Month') AS Casedate, To_Char(myDate,'month') AS lowdate ''
I guess it's not something I've ever used nor paid attention to, but it's still kinda cool to know.

Now, back to ColdFusion:

For the Year difference, DateFormat() doesn't seem to have the problem, but DateTimeFormat() does. Interesting. And Lucee/Railo gets even weirder. http://trycf.com/gist/908f3b1ed6d7490bc470/acf11?theme=monokai

<cfscript>
myDate = CreateODBCDateTime('12/30/2015 12:34:56.789') ;
writeDump(dateFormat(myDate,'mm/dd/yyyy')) ;
writeDump(dateFormat(myDate,'mm/dd/YYYY')) ;
writeOutput('<br>') ;
writeDump(dateTimeFormat(myDate,'mm/dd/yyyy')) ;
writeDump(dateTimeFormat(myDate,'mm/dd/YYYY')) ;
</cfscript>

Will return "12/30/Y'Y'Y'Y" for the dateTimeFormat(), but the proper date for simple dateFormat(). Isn't that old pre-CFMX behavior?

The other mask that bugs me is "S" and "s". "s" is Seconds and "S" is milliseconds, except for when "l" or "L" are milliseconds. And, "S" returns Seconds in dateTimeFormat() and timeFormat(), where it returns the milliseconds in dateFormat(), which technically doesn't even specify a time component to return. ARGH!!!!

Once again, CONSISTENCY CONSISTENCY CONSISTENCY. And the case of a mask shouldn't affect its functionality. There's just too much room for a silent error.

Anyway, that's enough for tonight. I guess these things are semi-documented in various places, but I still don't like it. It just seems way too common to not be an issue. The Adobe ticket says the documentation in CF was fixed to be clearer. I'll check that. And I need to pull down CFDocs and change the date function masks to note these differences in behavior. But this post became the rabit hole that I warned about earlier.


===== OTHER NOTES ========================================================

CF > DateFormat() vs DateTimeFormat()
DateFormat -
 9 = http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ff4.html
 10+ = https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/DateFormat.html

TimeFormat - http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6de0.html
DateTimeFormat - CF10+ - https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/DateTimeFormat.html
 "The function also follows Java date time mask. For more information, refer to Date and Time Patterns topic in SimpleDateFormat Java API page."

--------------------------

<cfscript>
myDate = CreateODBCDateTime('12/30/2015 15:16:17.19') ;
writeDump(dateFormat(myDate,'s')) ; // 17
writeDump(dateFormat(myDate,'S')) ; // 190
writeDump(timeFormat(myDate,'s')) ; // 17
writeDump(timeFormat(myDate,'S')) ; // 17
writeOutput('<br>') ;
writeDump(dateTimeFormat(myDate,'mm/dd/yyyy hh:nn:ss.l')) ; // 12/30/2015 03:16:17.190
writeDump(dateTimeFormat(myDate,'mm/dd/YYYY HH:NN:SS.L')) ; // 12/30/2016 15:16:17.190
writeOutput('<br>') ;
writeDump(datePart('yyyy',myDate)); // 2015
writeDump(datePart('YYYY',myDate)); // 2015
writeOutput('<br>') ;
writeDump(dateAdd('yyyy',1,myDate)); // {ts '2016-12-30 15:16:17'}
writeDump(dateAdd('YYYY',1,myDate)); // {ts '2016-12-30 15:16:17'}
</cfscript>
>>>>>>>>>>>>

http://trycf.com/gist/5a4209466ccf5e5ea854/acf11?theme=monokai
http://trycf.com/gist/ef686d4c4bf45fb85619/acf11?theme=monokai
http://trycf.com/gist/b24b9c91e6cee5e3c12e/acf?theme=monokai
http://trycf.com/gist/9db92000bb204a561edd/acf?theme=monokai

Links:
Original CFDocs Issue: https://github.com/foundeo/cfdocs/issues/266
http://www.sql-server-helper.com/tips/date-formats.aspx
http://www.java2s.com/Tutorial/Java/0040__Data-Type/SimpleDateFormat.htm
https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-by-category/date-and-time-functions.html
https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/DatePart.html
http://www.petefreitag.com/cheatsheets/coldfusion/dateformat/
https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/DateFormat.html




Friday, February 26, 2016

ColdFusion Scope Precedence

A while back (August 2015), Himansu Sekhar Khuntia logged a bug for ColdFusion 10 that dealt with the scope precedence of LOCAL and ARGUMENTS scopes within a function, and specifically how unscoped variables were effected with CF's scope hunting. Current behavior of ColdFusion 10 has ARGUMENTS taking precedence over LOCAL, and I really don't know how far back this problem goes, but apparently the behavior should be LOCAL over ARGUMENTS.

Original bug report for CF10: https://bugbase.adobe.com/index.cfm?event=bug&id=4031746
Possibly related for CF2016: https://bugbase.adobe.com/index.cfm?event=bug&id=4119653

Inside a function, LOCAL scope SHOULD take precedence over ARGUMENTS scope. This is fixed in 2016 (need to try it out) and planned to be fixed in 10/11. We'll see which patch it makes it into.

To make things interesting, I decided to play with the function scopes in CF10 (pre-scope order fix), and got some interesting results. See below.

Moral of the Story: ALWAYS SCOPE YOUR VARIABLES!!!!! To be extra safe, it probably wouldn't be a bad idea to try to keep from naming a variable the same in multiple scopes. ARGUMENTS and LOCAL are SUPPOSED to be mutually exclusive, but they aren't always.

Anyway, thank you to Adobe for actually clarifying that. Now I need to start reporting the discrepancy when I see it documented incorrectly, ie http://www.learncfinaweek.com/week1/Scopes/.

========================================================================


Friday, February 19, 2016

ColdFusion 2016 Has Officially Dropped!

I meant to post this a few days ago when it actually happened, but I'm slacking again. The newest iteration of Adobe's ColdFusion has been released! They went away from their previous numbering scheme: this isn't ColdFusion 12, this is ColdFusion 2016. Interesting. And I'm not sure I like it much. By 2017, we'll already sound out-of-date. Can you imagine what CF2012 (CF10) or CF2014 (CF11) would sound like? And CF10 is still a HUGE part of the ColdFusion landscape. Besides, we really need a more positive impression of ColdFusion.

Anyway, I doubt work will get to this new version any time soon, and I'm kinda glad for that. I can already see a lot of things that will need to be refactored to function correctly. Hopefully some of these issues are on the roadmap to be fixed.

The safe navigation operator (?.) is kinda cool, and a built-in CLI is interesting (though I don't yet know how I'd use it). And moving the default install for CFIDE and the CFAdmin is LONG overdue. Hopefully that will cut down on some of the "security problems" that resulted from bad installations and not locking down servers.

I'll play with this one at home some more when I make some time to get a VM for it up and running again.

Here are some announcement links:

http://blogs.coldfusion.com/post.cfm/announcing-the-launch-of-the-newest-version-of-coldfusion-adobe-coldfusion-2016-release

https://helpx.adobe.com/coldfusion/whats-new.html
https://helpx.adobe.com/coldfusion/release-note/coldfusion-2016-release-notes.html


Monday, February 1, 2016

State of the CF Union Survey 2016

http://www.teratech.com/blog/index.cfm/2016/1/20/State-of-the-CF-Union-Survey-2016

Follow the link and take the survey.

Thursday, January 21, 2016

Unhelpful Error Message

Since we're already well into January, it's probably a bit late for well-wishes for the New Year. At least it's timing is consistent with my postings here. New Year's Resolution 1: Reduce Procrastination Time. New Year's Resolution 2: Don't Wait Until Almost February To Make New Year's Resolutions.

Anyway, on my dev note, I've been doing this a long time, and I've seen some very odd error messages pop up. Last week, I received the most unhelpful ColdFusion Error Message I think I've ever seen: "6". Yup, that was the entire error message.

I got it on a Query of Query that had a UNION in it. I know QoQ is very limited in what you can do, but a UNION should work. I could run each statement individually in the query, and I could run them both together as a UNION in SQL Developer, just not in my CFC. Syntactically, there was nothing wrong with my query. Regardless, I moved on.

Turns out, it was an error buried deep in the Java handler that apparently didn't have a good way to be returned, so the actual error that bubbled back up to ColdFusion was a java.lang.ArrayIndexOutOfBoundsException type with no Error Message passed through.

Still though, "6"???