(Lucee) Dealing with a massive old application wit...
# lucee
b
(Lucee) Dealing with a massive old application with tons of files that get accessed in too many different ways (directly, though fuseactions, cf tags, includes, cfcs, cfm's with udfs, etc...) and trying to determine what's actually used so things that aren't can be deleted. My thought was to create a custom debug template that just logs all the template data to newrelic or wherever. After letting that run for a while, we should have a list of every file used in the application so it can be used to determine which files in the repo are never accessed. I'm wondering if anyone has other ideas for accomplishing this. The thought of enabling debugging in prod (even with a lighter weight custom debug template) is giving me pause. I have done something similar but it was in a QA environment which obviously has far less traffic than production so there wasn't much concern there.
r
I created a lightweight custom logger in my Application.cfc onRequestStart method for something similar, although the app had ~1100 files all in the root and no CFCs.
Logged everything to a database table with no indexes (except identity column).
d
We’ve also done something in the onRequestStart to log some stuff to a database so we knew what pages were being used as we tried to replace an old application. We just logged some cgi variables (script_name, path_info, query_string, etc.) so it was less about specific files though.
➕ 1
b
How did you get a list of all the templates used in onRequestStart?
just getting the current template name or "target page" isn't enough. I need to also get all referenced files whether that be CFCs because a function in it was called or a cf_tag was used or cfinclude. Basically everything you see in the list of templates when you turn on debug output is what I need to log
even callStackGet() only shows the parent template in onRequestStart but there are about 30 files listed in the debug output's template list
also...
~1100 files all in the root and no CFCs
Ouch lol
e
this is syntax from an old project that got the call stack info from callStackGet()
Copy code
<cfscript>
	var _ = {};
	_.op = arrayNew(1);
	_.trace = CallStackGet();
	_.elCount = arrayLen(_.trace);
	for (_.i = 1; _.i Lte _.elCount; _.i = _.i + 1) {
		_.info = {};
		_.info["Template"] = _.trace[_.i].template;
		_.info["Function"] = _.trace[_.i].function;
		_.info["LineNumber"] = _.trace[_.i].LineNumber;
		arrayAppend(_.op, duplicate(_.info));
	}
</cfscript>
b
Do you recall where you were using that? was it in onRequestStart? callStackGet() or dump in onRequesStart() only ever outputs Application.cfc for me.
e
oh interesting, yes this was called in the context of the bottom of a page request so i guess wouldn't show from the application level, sorry
unless you add something to every single file ...
b
right, exactly
e
i think your custom debug template is probably the best bet, or maybe FusionReactor
b
Yeah, I think so as well still. I'll likely head down that route and measure performance
thanks all rubber duck
...and I guess figure out how to make it a lucee extension to place the custom template cfc
s
Just thinking outside the box here, with the disclaimer “I have not tried this at home”, if you’re running on windows, would windows security file auditing work on the cfc, cfm folders and log which files were opened by lucee?
b
I'm not sure what auditing you mean. I've never seen anything in Windows that would do that. Yes though, it is (currently) running on Windows but, once we get our file storage moved to S3, the app will move to linux. The debug template is working quite nicely so far though