Suggestion: create a deprecated() function in Koha.
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}." : "" ); }
I've seen this sort of thing in a few projects and it works reasonably nicely.. though I'm not sure how it would work in Koha as we seem to replace all calls to a function and remove the function at the same time. If we did switch to this approach I'd suggest adding code to allow it to report to HEA so we can see the general adoption at the core level before nuking functions entirely. Juries out from my end as to whether this is a good or bad idea as a whole though I'm afraid. Martin *Martin Renvoize* Development Manager *T:* +44 (0) 1483 378728 *F:* +44 (0) 800 756 6384 *E:* martin.renvoize@ptfs-europe.com www.ptfs-europe.com <https://www.ptfs-europe.com> Registered in the United Kingdom No. 06416372 VAT Reg No. 925 7211 30 The information contained in this email message may be privileged, confidential and protected from disclosure. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this email message in error, please email the sender at info@ptfs-europe.com On 22 June 2018 at 21:52, Barton Chittenden <barton@bywatersolutions.com> wrote:
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}." : "" ); }
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
Hi Barton, I usually follow the same pattern for the commit messages when I remove a subroutine from C4. We could list them (something like `git log|grep "Move (.*) to Koha::*"`) for each release then provide a script to catch removed subroutine. However it will not help to know in advance (version N-1) if the plugin will still work. I do not think it will help much to have the deprecated function, we change the prototype of our subroutines very often, that will also break the plugin. I should also add that when a sub is removed it's not only moved to Koha, code from callers is adjusted and completely different. It cannot be done in some cases I think. The best still is to have a good test coverage for the plugin ;) Cheers, Jonathan On Fri, 22 Jun 2018 at 17:52 Barton Chittenden <barton@bywatersolutions.com> wrote:
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}." : "" ); }
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
participants (3)
-
Barton Chittenden -
Jonathan Druart -
Renvoize, Martin