[Koha-devel] Suggestion: create a deprecated() function in Koha.
Barton Chittenden
barton at bywatersolutions.com
Fri Jun 22 22:52:11 CEST 2018
It would be useful for Koha to have a 'Deprecated' function, which would
send a warning about the caller() function and the version of Koha where
the function will be deprecated, and what it will be replaced by... so
let's say that C4::Adequate::DoEET() is being replaced by
Koha::Awesome->sauce(). in Koha 18.11.
In versions of koha prior to 18.11, we add a call to
deprecated( "18.11", "Koha::Awesome->sauce()");
at the beginning of C4::Adequate::DoEET().
Then, when C4::Adequate::DoEET() is called, this would generate the
following message in the logs:
"C4::Adequate::DoEET is deprecated and will be removed in Koha 18.11. It
will be replaced by Koha::Awesome->sauce()."
This would allow plugin authors to know that they will need to patch their
plugins before they break on upgrade.
This is a bare-bones implementation of deprecated():
sub deprecated {
my ( $version, $replacement ) = @_;
my (
$package, $filename, $line, $subroutine, $hasargs,
$wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash
) = caller(1);
warn(
"${subroutine} is deprecated and will be removed"
. " in Koha version $version."
. defined( $replacement )
? " It will be replaced by ${replacement}."
: ""
);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20180622/cf5ca81a/attachment.html>
More information about the Koha-devel
mailing list