Bugzilla – Attachment 194378 Details for
Bug 41974
Remove C4::Context from Koha::Object
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41974: Remove C4::Context from Koha::Object
4afd70f.patch (text/plain), 2.30 KB, created by
Jonathan Druart
on 2026-03-03 12:54:05 UTC
(
hide
)
Description:
Bug 41974: Remove C4::Context from Koha::Object
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2026-03-03 12:54:05 UTC
Size:
2.30 KB
patch
obsolete
>From 4afd70fa0f25386e06aea7103e55366e283e7f19 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 2 Mar 2026 14:14:49 +0100 >Subject: [PATCH] Bug 41974: Remove C4::Context from Koha::Object > >--- > C4/Context.pm | 7 +------ > Koha/Config.pm | 13 ++++++++++++- > Koha/Object.pm | 3 ++- > 3 files changed, 15 insertions(+), 8 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 74ccd9f5597..3834c2a0038 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -778,12 +778,7 @@ sub get_versions { > =cut > > sub tz { >- my $self = shift; >- if ( !defined $context->{tz} ) { >- my $timezone = $context->{config}->timezone; >- $context->{tz} = DateTime::TimeZone->new( name => $timezone ); >- } >- return $context->{tz}; >+ return Koha::Config->get_instance->timezone_dt; > } > > =head2 IsSuperLibrarian >diff --git a/Koha/Config.pm b/Koha/Config.pm >index 3b01e760642..71ddbd903a7 100644 >--- a/Koha/Config.pm >+++ b/Koha/Config.pm >@@ -68,7 +68,9 @@ file will be read only the first time. > > =cut > >-our %configs; >+our %configs = (); >+ >+our $timezone_dt = undef; > > sub get_instance { > my ( $class, $file ) = @_; >@@ -214,6 +216,15 @@ sub timezone { > return $timezone; > } > >+sub timezone_dt { >+ my ($self) = @_; >+ >+ unless ( defined $timezone_dt ) { >+ $timezone_dt = DateTime::TimeZone->new( name => $self->timezone ); >+ } >+ return $timezone_dt; >+} >+ > sub _read_from_dom_node { > my ( $class, $node, $config ) = @_; > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 55c7e489a06..6bcf2b1caba 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -28,6 +28,7 @@ use List::MoreUtils qw( any ); > use DateTime::Format::MySQL; > > use Koha::Database; >+use Koha::Config; > use Koha::DateTime::Format::RFC3339; > use Koha::DateTime::Format::SQL; > use Koha::Exceptions::Object; >@@ -880,7 +881,7 @@ sub _recursive_fixup { > $value = $dtf->format_date($dt); > } else { > my $dt = Koha::DateTime::Format::RFC3339->parse_datetime($value); >- $dt->set_time_zone( C4::Context->tz ); >+ $dt->set_time_zone( Koha::Config->get_instance->timezone_dt ); > $value = $dtf->format_datetime($dt); > } > } catch { >-- >2.43.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41974
: 194378