This section provides remedies for some of the compatibility issues listed in "CFML tags and attributes" and "CFML functions and variables".
Note: For the most current information on ColdFusion MX compatibility, see the Support section of the Macromedia website (http://www.macromedia.com/supporthttp://www.macromedia.com/support).
The cfregistry
tag is deprecated for UNIX and Linux platforms. Therefore, you must remove it on UNIX-based versions of ColdFusion to avoid compatibility problems when migrating to a later version of ColdFusion MX.
As an alternative, you can use the store variables in the following scopes:
In Windows, you can continue to store client variables in the registry as in ColdFusion 5. However, you should not use the cfregistry
tag to read ColdFusion server settings from the registry, such as the mail root and information about Verity collections and scheduled tasks, because much of this information is no longer stored in the registry, or it is in a different location in the registry. The ColdFusion server settings that are stored in the registry are subject to change. Therefore, you should not rely on registry keys that ColdFusion creates to store its system settings.
Following are two common examples of using the cfregistry
tag in ColdFusion 5 that are not compatible with ColdFusion MX.
In ColdFusion 5, the following sample code checks if a Verity collection exists, and if not, creates one in the appropriate directory relative to the installation path. In ColdFusion MX, this sample code throws an error, because ColdFusion MX does not store information about Verity collections and the installation directory in the registry.
<CFREGISTRY ACTION = "GETALL"
Branch = "HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\ Collections" Type = "KEY" Name = "Collections"> <CFSET CollectionFound = 'No'> <CFLOOP QUERY = "Collections"> <CFIF Collections.Entry IS request.datasource> <CFSET CollectionFound = 'Yes'> </CFIF> </CFLOOP> <CFIF CollectionFound IS 'No'> <!--- Create the collection ---> <CFREGISTRY ACTION = "GET" Branch = "HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\ Collections" Entry = "RootDirectory" Type = "STRING" Variable = "CFRootDir"> <CFIF Server.OS.Name IS NOT "UNIX"> <CFSET CollectionPath = "#CFRootDir#\Verity\Collections\"> <CFELSE> <CFSET CollectionPath = "#CFRootDir#/verity/collections/"> </CFIF> <CFCOLLECTION Action = "CREATE" Collection = "#request.datasource#" Path = "#CollectionPath#" Language = "english"> </CFIF>
In ColdFusion MX, you cannot retrieve a list of Verity collections that are registered by ColdFusion or the K2 Server using the registry. Instead, use cfcollection
with action="list"
, perform a Query of Queries on the queryResult
that is specified in the name
attribute of cfcollection
, and use cfdump
to display the collections. Following is sample code to accomplish these tasks:
<cfcollection action = "list" name = "verity" >
<cfoutput>List of all known verity collections.<br><br></cfoutput> <CFDUMP var = "#verity#"> <br> <cfoutput>Searching for a specific collection by name.<br><br></cfoutput> <cfquery name = "qoq" dbtype = "query"> select * from verity where verity.name = 'test_db_neo' </cfquery> <br> <CFDUMP var = "#qoq#">
This returns a table of every collection that is registered by ColdFusion or the K2 Server. The table has the following columns:
The following example to retrieve ColdFusion mappings throws an error because ColdFusion MX does not store ColdFusion mappings in the registry.
<cfregistry action = "get"
branch = "HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\ Templates" entry = "/cfdao/" type = "String" variable = "RegValue"> <cfif isdefined("regvalue")> <cfset request.cfdao_mappeddir = "#regvalue#"> <cfelse> <cfoutput> Please create a CF Mapping named cfdao which points to your cfdao files before trying to run this template. </cfoutput> <cfabort> </cfif> <cfinclude template = "/cfdao/dao_application.cfm">
To work around this, you can include error handling in your templates that would notify the system administrator if a cfinclude
failed due to a missing mapping. In the event of a missing mapping, the system administrator must create it in the ColdFusion Administrator.
For more information on performing registry operations in ColdFusion MX, see cfregistry
in the CFML Reference.
When sorting with textnocase
in a descending order, ColdFusion 5 and ColdFusion MX return the results in a different order. However, both are correct because in a textnocase
sort, "apple" is equal to "APPLE".
In ColdFusion MX, a descending textnocase
sort returns the elements in the exact reverse order as in an ascending textnocase
sort. This is different than in ColdFusion 5.
The following code produces different results in ColdFusion MX than in ColdFusion 5:
<cfset list = "orange,Orange,apple">
<cfset listAsc = ListSort(#list#, "textnocase", "asc")> <cfset listDesc = ListSort(l#list#, "textnocase", "desc")> <cfdump var = #listAsc#> <cfdump var = #listDesc#>
This code produces the following results for ascending and descending sort operations in ColdFusion 5 and ColdFusion MX:
Sort order |
ColdFusion 5 results |
ColdFusion MX results |
---|---|---|
Ascending ( listAsc ) |
apple, orange,Orange |
apple,orange,Orange |
Descending ( listDesc ) |
orange, Orange, apple |
Orange,orange,apple |
For more information, see ListSort()
in CFML Reference.
To populate a collection with the contents of the query results, you can now use the cfindex
tag with the query
attribute and type
=
"file"
or type
=
"path"
, for all actions that require information from the key
attribute. You can also still use type
=
"custom"
.
When you use type
=
"file"
or type
=
"path"
with a query, the action
attribute queries to get filenames or file paths from the key
attribute, and passes the query results to its actions. The actions use the filenames or file paths to execute their code.
The following table shows a sample database for an application on a Windows server:
You can populate a collection using either of the following scripts:
snippets
collection with files specified in the description column of the database, as shown in the following example:
<CFQUERY NAME = "bookquery" DATASOURCE = "book"> SELECT * FROM book where bookid='file' </CFQUERY> <CFOUTPUT QUERY = "bookquery"> #url#,#description# <BR> <cfindex collection = "snippets" action = "update" type = "file" query = "bookquery" key = "description" URLPath = "url"> </CFOUTPUT>
snippets
collection with paths specified in the description column of the database, as shown in the following example:<CFQUERY NAME="bookquery" DATASOURCE="book"> SELECT * FROM book where bookid='path1' or bookid='path2' </CFQUERY> <CFOUTPUT QUERY="bookquery"> #url#,#description# <BR> <cfindex collection="snippets" action="update" type="path" query="bookquery" key="description" URLpath="url" > </CFOUTPUT>