How do I locate a custom tag instantiation in a coldFusion App
Asked Answered
P

1

8

I am migrating a very old app (currently running in CF8) to Lucee. But I am running into a problem with what appears to be a custom tag of some sort.

I have tried to make sure that all the virtual directories are the same in IIS for both the old and the new installs. And made sure the mapping and custom tag paths in both the CFIDE and the Lucee Admin are the same.

But I am getting this error. And can't figure out how this cflink is being instantiated.

enter image description here

enter image description here

I have found the location of the erroring code on line 300 the utils.cfc file enter image description here

I haven't used custom tags in a long time but thought they were generally called with an underscore and the code should like more like <cf_link pageid="#LinkPageID#" Init="start"> if this was being called as a custom tag.

If I go the the current CF server that is running this app I can find that a cfclass files HAS been created enter image description here From a file called cflink.cfm in a directory called "tags" even though there seems to be no mapping for the "tags" directory nor is is listed under "custom tags paths" in the administrator.

This App was start in 2003 and as you can imagine has grown into a mis-match of spaghetti code and no one from the beginning is around to ask how this tag is instantiated.

Does anyone with experience in legacy code has any other ideas where I should be looking to try to get this to work? The currently has only a production environment and if I can get it to work on Lucee it will not only be a dev environment that hasn't existed here in 10 years but will be a great way for me to be able to continue showcasing Lucee as a great CFML engine

Adding addition info

Leigh had asked if the init might be a jar reference but in the cflink.cfm file I see this code:

    <cfif Attributes.Init IS "start">
        <cfset Request.PageID = Attributes.PageID>
        <cfset Request.Page_Width = Variables.qParentInfo.Page_Width>
        <cfset Request.Page_Height = Variables.qParentInfo.Page_Height>
        <cfset Request.Page_TypeID = Variables.qParentInfo.Page_TypeID>
        <cfset Request.AddPath = "">
        <cfif IsDefined("Attributes.Anchor")>
            <cfset Request.Anchor = Attributes.Anchor>
        <cfelse>
            <cfset Request.Anchor = "">
        </cfif>
        <cfset Request.IsInternalLink = false>
        <cfexit method="EXITTAG">
    </cfif>

There are also references to cflink in the code inside tags\cflink.cfm

<cfif Len(Variables.qParentInfo.ParentID) GT 0>
    <!--- Add the page title to the end of the path --->
    <cfset Request.AddPath =  ReplaceNoCase(Variables.qParentInfo.Nav_Title," ","_","ALL") & "/" & Request.AddPath>
    <cflink init="working" pageid="#Variables.qParentInfo.ParentID#" popcode="#Attributes.popcode#">
<cfelse> ......</cfif>

Although this may be recursion given it was written in 2004 I kind of doubt it

Adding screen shots of searches

enter image description here enter image description here

Preengage answered 8/12, 2015 at 20:19 Comment(16)
Shot in the dark, but did check for any cfimport calls? You can do some creative things with tag libraries.Toomin
Try doing a search on your server on link.cfm. It has to be somewhereLundeen
Sounded like they did that: "...From a file called cflink.cfm in a directory called "tags"... ?Toomin
I was thinking of one without the cf part. Doesn't cf_ get added automatically or is Lucee different?Lundeen
there is no cf_ I mentioned that specifically since every other custom tag seems to always be called that way (with the underscore) but in the case of this cflink there is never an underscorePreengage
James - Well, I am not so sure it is a custom tag. IIRC, ACF forbids custom tags from starting with "cf" (without an underscore). The only exception I could think of was if maybe it is part of a tag library, ie cfimport? (Edit) @Preengage - Did you do a search for cfimport?Toomin
I did a full search of all the code and there is only 1 instance of the cfimport tag in the app and that is being used to import Ben Nadel's POI utilities. So if is isn't being imported and it can't be a custom tag because there is no underscore and it IS being converted to a cfclass on the cf8 box how is this happening ?Preengage
Suggestion 1: Did you do a search on GETPAGEPATHS . That looks like a custom function inside of cflink.Lundeen
Suggestion 2: Maybe what you need to look for is not a cfm file. Maybe they got some non cfm file to be the custom tag. Try searching on cflink.*Lundeen
Honestly, I am not sure. I have never heard of a way around the naming restrictions, (at least not with standard CF code) but could not rule it entirely. If you examine the contents of data\cflink.cfm file does the code suggest it what is used by the <cflink...>? Might not. Also, long shot, but .. are there any custom jars in the class path or WEB-INF\lib? (Edit) James - Yeah, searching for non-tag references to cflink (only) is a good idea. The name "init" made me wonder if it might be some sort of java tag?Toomin
I have now looked in the /lib directory for any possible jar files that might be called link.jar or cflink.jar no luck.As for what the tag is doing.. the tags/cflink.cfm file runs a couple of queries against a database and then handles links (anchors) in our legacy proprietary cms and deals with them slightly differently based on criteria. But the instantiation is boggling me and I have used a LOT of time tracking is down, time to pull my hair outPreengage
I did add some additional info to the question, specifically about the init that was mentionedPreengage
@Preengage - Well, jars can be named anything you want, so a name search alone would not necessarily do the trick. Like with a .zip file, the actual contents must be examined. However, jars/jsp tags was a long shot. Based on the updated code, it does seem like data\cflink.cfm is the file referenced in the code (unless it is old code that was never removed ;-). If so, I am baffled as to how they did it. Anyway, for grins, what happens if you use <cf_link>, rather than <cflink>?Toomin
@Toomin - If I change it to <cf_link> it DOES seem to bypass that specific error but then I get a new error the function init has an invalid return value , can't cast null value to value of type [this] but I am not sure if it is related or not. I understand that a jar file is a compiled file and could contain anything. the names for sure do not represent anything like link or cflink but there are several jars that have obsure name. Is there an easy to search their contents?Preengage
Any tool that can search .zip files should do the trick. 7zip, TotalCommander, etcetera. I do not think windows lets you search jars by default, but you could always make a copy (for safety) and rename it from *.jar -> *.zip That should make windows happy and let you search the contents.Toomin
I was about to search the coldFusion8 directory jar, exe everything. I was about to find some references to the cflink but when I try to view the files I get very limited ability to see anything (images added to question above). Do you know if there is anything I can install on the server that is working to be able to see what is happening, which files are being files and what order? We have a license for SeeFusion but it doesn't give that kind of detail.. I have also deleted the files in the web-inf\cfclasses and turned off "Save classes" in the adminPreengage
P
4

If anyone else runs into this. In CF8, and presuming earlier versions, you could put a cfm file into the ColdFusion8\wwwroot\WEB-INF\cftags Directory and that file in this case ColdFusion8\wwwroot\WEB-INF\cftags\link.cfm Then acts as any other cftag.

I was able to find the person who originally build this app in 2004 and he told me that they did it this way to avoid typing the underscore that they would have typed if they'd done it as a custom tag.

I kind of get it since this tag is used everywhere in the app, literally hundreds of times. Bit boy with a bitch to find.

Now all I have to do is figure out how to move it to the Lucee world in a similar fashion. So it instanciates the same way.

Thanks @Leigh for all your help, you are always amazing!

Adding more information

if there are files in the WEB-INF\lucee\library\tag the corresponding Lucee directory is WEB-INF\lucee\library\tag. These files are read on load and then able to be used as any other cf tag.

For example if you have file WEB-INF\lucee\library\tag\link.cfm it can be called by `cflink'.

Seems like a cool idea but a bit of a bitch for someone to find 10 years after the fact

Preengage answered 11/12, 2015 at 20:44 Comment(3)
Wow... never knew you could do that! Great job on solving the mystery. Do you know if Lucee allows it too? I seem to recall you could create "cf" tags without the underscore in Railo, albeit not in quite the same way. since this tag is used everywhere in the app.. Hehe, don't you just love legacy apps? ;-)Toomin
That is what I am working on now. I will post it in my answer when I get it figured out. Thanks again for your helpPreengage
You are very welcome. I look forward to it. (Guess, legacy apps may not always be fun, but they are never boring).Toomin

© 2022 - 2024 — McMap. All rights reserved.