Migrating from ColdFusion 5 to CFMX

Download Report

Transcript Migrating from ColdFusion 5 to CFMX

Migrating from ColdFusion 5 to CF MX
Sandra Clark
Shayna Productions
www.shayna.com
[email protected]
Agenda







2
ColdFusion Code Compatibility Analyzer
Migration Plan
Definite Code Breaking Changes
Possible Code Breaking Changes
Subtle Changes
Session Management and Locking
Questions and Answers
ColdFusion Code Compatibility
Analyzer


Located in the ColdFusion Administrator
Will check for the following issues
–
–


3
Obsolete and Deprecated Features
Items which might produce different results in
ColdFusion MX
Good starting point
Code still needs to be gone through by
thorough testing.
Migration Plan

What is a Migration Plan
–

Migration Plan Steps
–
–
–
–
–
–
–
4
A structured strategy to ensure that items running smoothly on CF5
run smoothly when ported to CF MX
Archive and Deploy a CF 5 Application to a Test Server running CF5
Test Application to make sure it runs correctly
Install CF MX onto the test server
Use the ColdFusion Code Compatibility Analyzer
Using the results of the Code Compatibility Analyzer and the
Migration Guide, determine what needs to be fixed.
Use a source code control system while making changes to source.
Test under Load!!!
Definite Code Breaking Changes




5
Advanced Security
CFLOG
Database Changes
Scoping
Advanced Security and CFLOG

Advanced Security
–
–
ColdFusion MX is now based on a totally new security model than
ColdFusion 5
All Tags and functions having to do with the security model are
obsolete.


CFLOG
–
–

Thread, date and time attributes are deprecated.
All of these attributes default to Yes. Setting any of these attribute
values to No will cause a runtime exception.
Log files no longer supported
–
6
CFAUTHENTICATE, CFIMPERSONATE, AUTHENTICATEDCONTEXT(),
AUTHENTICATEDUSER(), ISAUTHENTICATED(), ISAUTHORIZED(),
ISPROTECTED()
–
Executive.log, Remote.log, Proxy.log, cfadmin.log, Install.log
Server.stdout, Rdsservice.stdout
Database Changes – Generic





7
ColdFusion MX now uses the JDBC Drivers instead of
ODBC or Native Drivers
All dbtypes except for “query” are obsolete
dbserver, dbname, connectstring, provider and
providerdsn attributes are obsolete
No more dsnless connections
CFUSION_DBCONNECTIONS_FLUSH is obsolete.
Database Changes – Generic

CFPROCPARAM
–

QUERY OF QUERIES
–

Will not let you use Reserved SQL words (date, size, etc) as field
names.
 Alias the names in your first SQL query and then use the aliased
names instead in the query of queries.
CFREPORT
–
8
Ignores the dbvarname attribute for all drivers.
 If your CF 5 application depends on this, specify a
CFPROCPARAM in the correct positional order.
No longer manages ODBC connection for Crystal Reports. Passes
datasource, username and password attributes to Crystal Reports for
it to handle the ODBC connection directly.
Database Changes – Generic

CFQUERY
–

QUERYADDNEW()
–
9
No longer allows SQL reserved words as variable or column names.
An invalid name passed in will throw an error.
 CF 5 – just continued.
Database Changes – Access

Memo fields


10
Does not work correctly with the default settings in ColdFusion
Administrator.
By default the CLOB and BLOB fields are unchecked. Check
both of these fields in the datasource Administrator to re-enable
Access Memo Fields
Database Changes – Oracle

Maxrows attribute is obsolete
–
11
Use CFPROCRESULT instead if you have ref cursors in packages or
stored procedures. This will cause DataDirect JDBC to place Oracle
ref cursors into a result set.
Database Changes – Oracle

Problems using the Secure Oracle Connection
–
–
–
12
Problem: When using the encryption/security features of Oracle, CF5
will connect correctly, CF MX will not.
Situation: While the Oracle thin client supports encryption, it does so
only when using the JDBC driver manager directly. ColdFusion MX
uses the datasource object to connect which doesn’t support the
encryption.
Solution: Use Oracles JDBC oci driver, which requires the oci
libraries. This driver will pick up the encryption properties from the
sqlnet.ora file. Download the driver and libraries from oracle. Use
Type other to configure the driver in ColdFusion MX. The class name
is oracle.jdbc.driver.OracleDriver and a sample url is
jdbc:oracle:oci8:@oracle_server
Scoping

All Client, Session, Server, Request and Attributes
scopes must be called with their appropriate scope.
–
–
–

The url variable requesttimeout is no longer supported.
–
–
13
Client.CFID instead of CFID
MX will no longer search the scopes for variables
Variables scope is the only exception for prefacing.
Use <CFSETTING requesttimeout=“”> instead.
Quick Fix <CFSETTING requesttimeout = “#url.requesttimeout#”>
Possible Code Breaking Changes









14
CFLDAP
CFGRAPH
CFAPPLICATION
CFREGISTRY
CFDIRECTORY
CFHTTP
CFSERVLET
CFSETTING
CFX TAGS





STRUCTKEYLIST()
FORM.FIELDNAMES
DATEDIFF()
ERROR HANDLING
VERITY
CFLDAP and CFGRAPH

CFLDAP
–
–

CFGRAPH
–
–
15
Sort attribute is deprecated
When action=“query” and dn is in the list of attributes.
 CFLDAP will consistently return each dn (distinguished
name) with a comma followed by a space.
CFGRAPH and CFGRAPHDATA are deprecated and will be
obsoleted. Use CFCHART, CFCHARTDATA and
CFCHARTSERIES instead.
Renders graphs slightly differently than in CF5
CFAPPLICATION and CFREGISTRY

CFAPPLICATION
–

CFREGISTRY
–
–
16
ClientStorage = “registry” is deprecated and will be obsolete in
later Unix versions of CF MX
Unix
 Deprecated and will be obsolete in future versions
Windows
 Do not use CFREGISTRY to read CF Server settings from
the registry.
 Much of the information is no longer stored in the registry or
are stored in different areas of the registry.
CFDIRECTORY

CFDIRECTORY
–
In Windows versions of CF MX


–
Unix, Linux versions

17
CFDIRECTORY will no longer return “.” or “..”
Sorting will only be supported on the ReadOnly and Hidden
Attributes.
When action=list, only the ReadOnly and Hidden attributes will
be reported.
CFHTTP

CFHTTP
–
–
–
18
Response headers now returned in Mixed Case.
Response headers now returned in random order
Status Code 200 now followed by “OK”
 CF5 returned “Success”
CFSERVLET CFSETTING, CFX Tags

CFSERVLET
–
–
–

CFSETTING
–

catchExceptionsByPattern Attribute is obsoleted.
CFX Tags
–
19
Deprecated
Using CFSERVLET to call methods on servlets will be obsolete
in future versions.
You can only call servlets which were created in JRUN version
3.1
Java CFX tags must have the class files in:
 <ColdFusion MX Installation Directory>/wwwroot/WEBINF/classes.
 CF 5 the class files were in <ColdFusion 5 Installation
Directory/Java/classes
STRUCTKEYLIST(), Forms

STRUCTKEYLIST()
–
–

Form.FieldNames
–
20
Returns Struct Keys in the order in which they were created,
not in alphabetical order
Returns in the case they were created in.
Returns Form.Fieldnames in the order in which they were
created and not in All Uppercase.
Error Handling

CFERROR
–
–
–

CFCATCH
–
–
–
21
type=“monitor” is now obsolete
Must now specify a template handler as a path relative to the
web root directory \error.cfm for web_root\error.cfm
Do not use the full path
Message variable gets the current values every time an
exception is thrown.
CF MX ignores any cfset assignment to a cfcatch object
member such as cfcatch.message.
CFCATCH can no longer be used to catch function validation
errors.
Verity

CFCollection
–
–

CFINDEX
–
–
–
22
Action attribute is now optional, its default value is “list” a
new value
A new attribute, “name” is required when action=“list”. This
retrieves a query object with the properties of every Verity
collection registered by CF MX or the K2Server
Key Attribute can be used for the query attribute, type-file or
type=path
Action=“Optimize” is now obsolete.
External attribute is no longer necessary.
Subtle Changes





23
Locale Formatting
CFX Libraries
Server Variables
Form Variables
Database Changes




Date Changes
Null Values
PI
Regular Expressions
Locale Formatting

LS Formatting works differently from CF 5 to
CF MX
–
MX uses Java locale standards in its locale specific functions
–
Previous versions of ColdFusion used either Windows or Unix localespecific rules depending on the platform.
By using Java standards, consistency is achieved across all
platforms. However, this means that lsParseDateTime will now
produce slightly different results than previous versions.
–
–

LSDATEFORMAT()
–
24
Listing of Java DateTime Formats
 http://www.inter-locale.com/demos/locales.jsp
doesn’t support mmm-dd-yyyy mask except in english locales
CFX Libraries


Do not need to be recompiled.
It does not matter where you place the libraries as long
as the location is set in the LD_LIBRARY_PATH.
–
–
25
This can be set in the cfstart.sh script ini "neo/bin"
LD_LIBRARY_PATH=/opt/neo/lib:/opt/neo/verity/_solaris/bin:/opt/myli
braries; export LD_LIBRARY_PATH
Server Variables

Certain Server Variables are giving different
information between CF 5 and CF MX
–
Server.OS.Name for Windows 2000


–
Server.OS.AdditionalInformation


–
Gives Service Pack Info for CF5
Gives nothing for CF MX
Server.OS.BuildNumber


26
Gives Windows NT for CF 5
Gives Windows 2000 for CF MX
Gives Build Number for CF5
Gives nothing for CF MX
Forms

Case
–
–
–
27
CF MX now preserves case in form.fieldnames instead of forcing
them to upper case.
Case is still ignored when evaluating field names.
Use FINDNOCASE() or LISTFINDNOCASE() when searching
form.fieldnames instead of the case sensitive alternatives
Database Changes

QueryColumn Object
–

Query Result Appearances
–

data being returned with space characters appended to end
Query Column Names
–
28
Acts more like an array
CF MX preserves case of column names.
 CF5 forced column names to lowercase.
Date Changes

Date Pivot for 2 digit years
–
–
–

Milliseconds
–

are no longer stripped off date/time objects.
DATEDIFF()
–
29
CF MX uses 20 as the date pivot for calculating the century
CF5 used 29
Certain locales use 28 as the date pivot.
One less second in a minute when calculating a negative difference in
CF 5
Null Values

CF 5
–

CF MX
–
30
converted all null values to an empty string
preserves null values, but converts them to an empty string when
used as simple values
PI and Operands


PI
–
Defined with a slightly different precision then CF5.
–
Would only cause slightly different results when using trigonometric
functions.
Operands
–
31
Exponent results will differ.
 For 0^3
– CF5 will return an error
– CF MX will return a 1
Regular Expressions


32
Now recognizes accented letters
Must escape the \ backslash character even if it is
inside a character class []
Session Management

J2EE Sessions
–
–
33
by default session management relies on j2ee session management,
which uses jrunsessionid as the session cookie. It is a session cookie,
when user close the browser, the cookie goes away, therefore the
session is terminated right there.
If Application has client management turned off and session
management is turned on using J2EE sessions you may not have
CFID and CFToken variables.
Session Management
Compatibility Fixes

Delete the lines in your code that use cfcookie to reset
the age,
–

Uncheck use J2EE session in the server settings page
on CF Admin.
–

34
no longer needed.
This will place CF MX in a compatible mode with the way CF5
operated.
This change requires a server restart
Variable Changes


Structures
–
Now preserves the case of a structKey
–
Different cases DO NOT create different keys
–
<cfset x.foo = 1> will now create a structure x with a key “foo”
without having to explicitly create x as structNew()
Duplicate URL Parameters
–
–
35
Now come across as a comma delimited list of values
CF 5 only the last value is passed.
ThisTag Changes

CF5
–

CF MX
–
36
allowed changes to the system values in the ThisTag Scope that
persisted throughout the execution of the tag.
Setting thisTag.hasend or thisTag.executionmode throws an
exception.
Locking

While MX uses Java Data Structures that are designed to be
thread safe, it is still considered best practices to lock
–
–
–

Must continue to lock for race conditions
–
37
Code that is correctly locked could (assuming it is otherwise correct)
be proved to do what it's intended to do. Code that is not correctly
locked may give different results depending on what other requests
may be concurrently modifying shared data; no theorem can account
for this.
Code that is correctly locked can be run on a CF MX installation or a
CF5 installation.
The <CFLOCK> tag has low overhead.
Application.incrementvariable = Application.Incrementvariable + 1
Questions and Answers

Where to get more information
–
–
Macromedia CF MX Migrating ColdFusion 5 Applications
MX Release Notes:

–
MX Doc Updates:

–
http://livedocs.macromedia.com/cfmxdocs/
Macromedia Designer & Developer Center:

38
http://www.macromedia.com/v1/handlers/index.cfm?id=22993&method=full
MX LiveDocs:

–
http://www.macromedia.com/v1/Handlers/index.cfm?ID=22811&Method=Full
MX Doc Additions:

–
http://www.macromedia.com/support/coldfusion/releasenotes/mx/releasen
otes_mx.html
http://www.macromedia.com/desdev/mx/coldfusion/
Extras
39
Changed Tags and Functions



40
Obsoleted
Deprecated
Changed
Obsolete Tags and Functions


CFAUTHENTICATE
CFIMPERSONATE





41
AUTHENTICATEDCONTEXT(),
AUTHENTICATEDUSER(),
ISAUTHENTICATED(),
ISAUTHORIZED(),
ISPROTECTED()
Obsolete Internal Functions











42
CF_GETDATASOURCEUSERNAME()
CF_ISCOLDFUSIONDATASOURCE()
CF_SETDATASOURCEPASSWORD()
CF_SETDATASOURCEUSERNAME()
CFUSION_DBCONNECTIONS_FLUSH()
CFUSION_DISABLE_DBCONNECTIONS()
CFUSION_GETODBCDSN()
CFUSION_GETODBCINI()
CFUSION_SETODBCINI()
CFUSION_SETTINGS_REFRESH()
CFUSION_VERIFYMAIL()
Deprecated Tags and Functions



CFGRAPH
CFGRAPHDATA
CFREGISTRY
–


43
(UNIX systems only)
CFSERVLET
CFSERVLETPARAM



GETSETTINGS()
GETTEMPLATEPATH()
PARAMETEREXISTS()
Changed Tags

CFFORM
–
–

Error Handling
–
–

CFCATCH
CFERROR
Verity
–
–
44
CFAPPLET
CFFORM
CFCOLLECTION
CFINDEX

Miscellaneous
CFAPPLICATION
CFCACHE
CFDIRECTORY
CFHTTP
CFLOG
CFLOOP
CFMAIL
CFPARAM
CFREGISTRY
CFREPORT
CFSETTING
CFSWITCH
CFQUERY
Changed Tags 2
Database
CFINSERT
CFQUERY
CFUPDATE
CFSTOREDPROC
CFLDAP
CPROCPARAM
45
Changed Functions

Arrays
–
–
–
–
–

Dates
–
–
–
–
46
ARRAYAVG()
ARRAYMIN()
ARRAYMAX()
ARRAYSUM()
ISARRAY()
DATEDIFF()
DATEFORMAT()
LSPARSEDATETIME()
PARSEDATETIME()

Lists
–
–
LISTSETAT()
LISTSORT()
Change Functions 2

Miscellaneous
–
–
–
–
–
–
–
–
–
–
47
DELETECLIENTVARIABLES()
GETBASETAGLIST()
GETLOCALE()
ISCURRENCYFORMAT()
GETTEMPDIRECTORY()
ISWDDX()
LEN()
REREPLACE()
REREPLACENOCASE()
STRUCTKEYLIST()