1

We are doing maintenance on a huge legacy system that was written over 10 years ago. It is all written procedurally with no concept of OOP. There are lots of includes and redirects all over the code. The problem is that it is extremely difficult to find where a specific event is calling a given cflocation.

Is there a way stop all cflocations from happening and instead create an error or something so we can find it? I was thinking it might be possible to add something to an onRequest method that might catch a cflocation and prevent it from working.

Lance
  • 3,193
  • 2
  • 32
  • 49
  • 3
    *stop all cflocations from happening and instead create an error* Crazy idea, but if this is just for debugging, what about using/abusing the sandbox security feature? I have not tried this, but you should be able to add `cflocation` to the list of restricted tags. That should cause an error to be thrown whenever that tag is invoked: an error you could trap. I am not sure onRequest/Start/End would work as a generic solution, unless maybe you checked the response headers for the [appropriate http code, ie 302](http://www.petefreitag.com/item/359.cfm). – Leigh Aug 09 '15 at 20:06
  • Agreed, crazy idea bordering on absurd, but we have literally tens of thousands of files (we are getting rid of the one that we can be assured aren't used) including file called things like add_customer_test.cfm that ended up being production code **sigh**. Hadn't thought about the sandbox security. I will give that a try, thanks – Lance Aug 10 '15 at 01:07
  • Having worked with a few monstrous legacy apps like that .. I can sympathize. They often required what I will euphemistically call .. "creative thinking". I do not know of any other way to disable a tag than sandboxing. However, you should also take a look at the request methods. In theory, you might be able to examine the headers to detect and trap relocations. – Leigh Aug 10 '15 at 02:01
  • 2
    Why not simply use a global search and place of `` ? – Adam Cameron Aug 10 '15 at 09:44
  • I would think a search on cflocation and entering a entry identifying each move would also work if you don't want to throw an error. Seems like Adam's suggestion should work as well if you do want to throw an error. – Gerry Gurevich Aug 10 '15 at 10:35
  • 1
    Which raises a good question: is modifying the codebase an option here? The sandbox idea is geared toward quick and easy debugging for a Dev environ, with minimal work and impact. However, obviously a find and replace would be the more robust approach. So is that an option? – Leigh Aug 10 '15 at 12:27
  • 1
    Following on from the above suggestion, if code change is allowed, replace all cflocations with a custom tag (e.g. cf_location) and you'll then have complete control to turn on/off or dump or just log. – Raspin Aug 12 '15 at 12:17

0 Answers0