[Koha-bugs] [Bug 36432] Remove circular dependency from Koha::Object

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Mar 26 16:51:16 CET 2024


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36432

Julian Maurice <julian.maurice at biblibre.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #163940|0                           |1
        is obsolete|                            |

--- Comment #2 from Julian Maurice <julian.maurice at biblibre.com> ---
Created attachment 163941
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163941&action=edit
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

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list