I’d err towards logging it, and probably display it in the debug output. Stuff that’s deprecated is - by definition(*) - still supposed to work as per normal, so not sure raising an exception if using a piece of deprecated functionality is that ideal.
–
Adam
(*) a definition. Possibly not your favourite one.
I think that this is a good plan. the only thing I’d add to step one is to log usage of that feature.
in my applications I added a simple custom tag that’s called Deprecated, which logs an optional message and the stack trace to a log file named deprecated.
then going over the log file it’s easy to see where there is still old code that uses the deprecated feature and update it.
ATM when a functionality is marked “as deprecated” this has no influence on the code executed.
The only influence is that this is shown in the documentation.
I would like to see the following functionality for this.
A switch in the admin with the following options:
How to handle if deprecated functionality is used?
(*) (default) do nothing
( ) show in debug output
( ) throw an exception
maybe with an interface that allows to extend this, so if you wanna add a new behaviour in case a deprecated functionality is used, you simply add a component looking like this in a certain directory, this way you can add your custom behaviour.
Example for logging to a log file (simplified):
/**
* This component add a new "deprecated" behaviour to the engine, it logs to a log named "deprecated"
*/
component displayName="Logger" {
public function getLabel(){// this is shown as a checkbox in the Lucee admin
return "Log";
}
public function getDescription(){// this is shown as a checkbox in the Lucee admin
return "Logs to a log file named deprecated.log";
}
/**
* @name name of the functionality that is deprecated and used, for example "ListTrim"
* @template file where the functionality is used.
* @line line of the file where the functionality was used
*/
public function onDeprecate(string name,string template, numeric line) localmode=true {// better name for this function?
log file="deprecated.log" text="#name# was used in file #file# on line #line#";
// you could even do things like
msg="#name# was used in file #file# on line #line#";
if(name=="listTrim") msg&=", use the function listCompat instead.";
log file="deprecated.log" text="#msg#";
}
}
this way we have the complete logic in CFML, the java code only bind it to the core
I’m all for this sort of approach to things in general. Second guessing some common use cases, but then exposing an interface for devs to handle things their own way as well.