2

We have a large number of legacy pages in our application's code repository which are not linked to other pages. Is there a way in ColdFusion Builder to see which pages are not linked so they can be deleted? (Builder is derivative of Eclipse, so the question may be answered by an Eclipse guru).

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Allen
  • 23
  • 4
  • Are you using a framework like ColdBox or FW/1? – James A Mohler Nov 02 '18 at 14:30
  • No. CF11+Apache/Linux+Oracle. – Allen Nov 02 '18 at 17:33
  • I would go with the logging `application.cfc`/`application.cfm` approach. – James A Mohler Nov 02 '18 at 17:40
  • 1
    If you have a long history of web logs, you could look through those to get a good starting point. Or you could use PowerShell to crawl through your site. You'll still need a way to find CFCs and any other page that isn't easily reported through CF. Logging and checking the stack trace would be very helpful. Regardless, you'll still need a way to exercise your site to get pages. Do you know about how many pages you're working with? – Shawn Nov 02 '18 at 17:56

2 Answers2

1

I would just search using "File Search" if the file name exists within the project.

Cfbuilder 3 search for a file with specific text inside a folder

If you use a framework such as FW/1 or ColdBox, you'll have to search for the model/view/controller name and not the exact filename.

Cory Fail
  • 1,070
  • 8
  • 26
  • Due to the size of the application and the number of subfolders, it is not really practical to search every page to see if it is linked or not. – Allen Nov 02 '18 at 15:43
  • 1
    CFBuilder does the search for you, and pretty quickly. I have used this feature many times looking for specific code bits in large enterprise applications. Here is also a similar question that has been answered. https://stackoverflow.com/questions/905855/how-do-i-determine-which-files-a-coldfusion-application-uses – Cory Fail Nov 02 '18 at 15:59
  • That would work for a single page at a time, but if OP is looking to map the entire site, could that work? – Shawn Nov 02 '18 at 17:26
  • Yes, I was hoping to generate a site map to simplify things. – Allen Nov 05 '18 at 20:13
  • Yes, I was hoping to generate a site map to simplify things. In pursuite of a more DIY approach, Ben Nadel had an article suggesting using a Java object to catalog the pages and includes. I have set this up locally and is saving referenced pages to a database. But I'm not sure if this will work for 'inbetween' pages which are visited for a moment to perform quick actions like updating tables before redirecting based on logical processing. – Allen Nov 05 '18 at 20:19
  • SELECT line, parent, template FROM qEvents WHERE type = 'Template' ORDER BY line asc – Allen Nov 05 '18 at 20:20
  • #line##ListLast(parent,"\")##ListLast(template,"\")# insert into SITESPIDER values('#ListLast(CGI.SCRIPT_NAME)#','#line#','#ListLast(parent,"\")#','#ListLast(template,"\")#') – Allen Nov 05 '18 at 20:21
1

I am going to paraphrase Tomalak's answer from 9 years ago. He originally wrote

A regex is not advisable. Since ColdFusion is quite flexible in the way files can be included or referenced, there will be no way to determine the definitive list of dependencies from the source code alone.

You could insert a <cflog> into each file and build a log from the running application. Examine the log after the application was active for a while and all functionality had been accessed at least once.

Source: How do I determine which files a ColdFusion application uses?

I would change that slightly...

You could insert a <cflog> into application.cfc or application.cfm to determinte which pages are being accessed.

After that list is compiled, then see if any of those files use <cfinclude> or createobject(), or <cfmodule>. Eventually all files will be accounted for.

I also find it useful to look at change dates. If no one has touched a file in 15 years, it probably isn't important.

Shawn
  • 4,758
  • 1
  • 20
  • 29
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • 1
    Sorry, James. I hate editing other's answers. I added backticks around `cflog` since SO stripped that piece of text out. :-/ – Shawn Nov 02 '18 at 16:40
  • Editing other's answers is often quite useful. As long as you are not changing the meaning of the question or answer, edits are usually good. If the question is based on a significant typo, then one should hesitate to edit. IMHO, Older questions / answers with lots of likes should not be changed. – James A Mohler Nov 02 '18 at 16:43
  • I know. I just don't like touching other people's stuff. :-) I wish SO would let you know when it suppressed something. "You could insert a into...: is a lot different than "You could insert a `` into...", and the only reason I even noticed was because it didn't seem like a typo you'd make. – Shawn Nov 02 '18 at 17:13
  • 1
    I think it's also worth noting Peter Boughton's answer at your link: **Put it into Git first!** Source control can be a lifesaver in situations like this. – Shawn Nov 02 '18 at 17:18
  • 1
    Michaela Light covers this to in: The Best Version Control System (3 Reasons Why It Matters to All ColdFusion Developers) https://coldfusion.adobe.com/2018/08/the-best-version-control-system-3-reasons-why-it-matters-to-all-coldfusion-developers/ – James A Mohler Nov 02 '18 at 17:25
  • 1
    One other big benefit to source control is that sometimes a file that isn't used may not always be unneeded. Those files were written for a reason. And they were removed for a reason. Some times that reason could change and that file (or something similar) needs to come back. Source control makes recovery fairly trivial. – Shawn Nov 02 '18 at 17:57
  • File search may not work: I inherited an app where a form page was named like `fooMaint.cfm` and the related action page was `foo_Action.cfm`. In the form tag, the action page was written out by doing a `replace('Maint', '_Action')` on the current template name. No actual references to the full action page names in the whole code base. – Adrian J. Moreno Nov 07 '18 at 20:00