]> git.koha-community.org Git - koha.git/commit
Bug 36432: Remove circular dependency from Koha::Object
authorJulian Maurice <julian.maurice@biblibre.com>
Tue, 26 Mar 2024 15:19:41 +0000 (16:19 +0100)
committerLucas Gass <lucas@bywatersolutions.com>
Tue, 28 May 2024 16:36:58 +0000 (16:36 +0000)
commit1a1313a9e05bdc98988fec27426c511d6534c69b
tree49f359861c6cdbc6bc3e7c01f461a238e16086b3
parent9dde1fddd0438131f8ae2bce156c2819fbee9c89
Bug 36432: Remove circular dependency from Koha::Object

Koha::Object depends on Koha::DateUtils, which depends on C4::Context,
which depends on Koha::Config::SysPref, which depends on... Koha::Object

Apart from the circular dependency, the dependency on C4::Context alone
is problematic as it loads a bunch of modules that are not needed at all
in Koha::Object (YAML::XS and ZOOM for instance).
As Koha::Object is used as a base for a lot of modules, we should take
care to only load the minimum required.

This patch moves some date parsing code to specific modules:
- Koha::DateTime::Format::RFC3339
- Koha::DateTime::Format::SQL

and it uses them in Koha::Object and Koha::DateUtils where it is
possible.

Test plan:
1. Do not apply the patch yet and run the following command:
   `perl -cw Koha/Object.pm`
   It should print several warnings about redefined subroutines, meaning
   there is a circular dependency.
2. Apply the patch
3. Run `perl -cw Koha/Object.pm`. It should only say:
   "Koha/Object.pm syntax OK"
4. Run the following command:
    prove \
        t/DateUtils.t \
        t/Koha/DateTime/Format/RFC3339.t \
        t/db_dependent/Koha/Object.t

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8d5299639e3f983e95fcf2a9d81febc1406bafdd)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit b0c862533d74505c8f4fa8760d809942973ea57c)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Koha/DateTime/Format/RFC3339.pm [new file with mode: 0644]
Koha/DateTime/Format/SQL.pm [new file with mode: 0644]
Koha/DateUtils.pm
Koha/Object.pm
t/DateUtils.t
t/Koha/DateTime/Format/RFC3339.t [new file with mode: 0755]
t/db_dependent/Koha/Object.t