From dc4814bd100812b67bb4ea10a7200bac99765617 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 Mar 2026 13:49:56 +0100 Subject: [PATCH] Bug 41975: Remove C4::Context from C4::Log --- C4/Log.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/C4/Log.pm b/C4/Log.pm index 603bc8695a1..ffcb733dba6 100644 --- a/C4/Log.pm +++ b/C4/Log.pm @@ -20,8 +20,7 @@ package C4::Log; # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; +use Modern::Perl; use Data::Dumper qw( Dumper ); use File::Basename qw( basename ); @@ -29,9 +28,11 @@ use JSON qw( to_json encode_json ); use Scalar::Util qw( blessed ); use Struct::Diff qw( diff ); -use C4::Context; use Koha::Logger; use Koha::ActionLogs; +use Koha::Context::UserEnv; +use Koha::Context::Interface; +use Koha::Context::Preferences; use vars qw(@ISA @EXPORT); @@ -77,10 +78,9 @@ sub logaction { # Get ID of logged in user. if called from a batch job, # no user session exists and C4::Context->userenv() returns # the scalar '0'. - my $userenv = C4::Context->userenv(); - my $usernumber = ( ref($userenv) eq 'HASH' ) ? $userenv->{'number'} : 0; + my $usernumber = Koha::Context::UserEnv->exists ? Koha::Context::UserEnv->get('number') : 0; $usernumber ||= 0; - $interface //= C4::Context->interface; + $interface //= Koha::Context::Interface->get_interface(); if ( blessed($infos) && $infos->isa('Koha::Object') ) { $infos = $infos->get_from_storage if $infos->in_storage; @@ -102,7 +102,7 @@ sub logaction { : undef; my @trace; - my $depth = C4::Context->preference('ActionLogsTraceDepth') || 0; + my $depth = Koha::Context::Preferences->get_value('ActionLogsTraceDepth') || 0; for ( my $i = 0 ; $i < $depth ; $i++ ) { my ( $package, $filename, $line, $subroutine ) = caller($i); last unless defined $line; @@ -193,7 +193,7 @@ sub cronlogaction { $action ||= "Run"; my $loginfo = ( caller(0) )[1]; $loginfo .= ' ' . $info if $info; - logaction( 'CRONJOBS', $action, $$, $loginfo ) if C4::Context->preference('CronjobLog'); + logaction( 'CRONJOBS', $action, $$, $loginfo ) if Koha::Context::Preferences->get_value('CronjobLog'); } 1; -- 2.43.0