From 25b9f408386d3d9e3df2b8c99ae99a57fdd230a7 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 19 Nov 2014 13:54:09 -0300 Subject: [PATCH] Bug 11998: (RM followup) avoid adding an unneeded workaround This patch aims to make my point explicit on how I think we should handle this bug. It removes the addition of a new logging facility, removes the introduction of logging on C4::Context (out if the scope of the bug, and already solved by the svc script, in the wrong place, I know). I'm still concerned about the addition of global variables in favour of a more OO design. I should note I'm not a Plack user so I KNOW I might not be getting a point on that very subject, so: Feel free to discuss and/or obsolete it. Best regards Tomas --- C4/Context.pm | 4 --- C4/LogStatic.pm | 96 --------------------------------------------------------- 2 files changed, 100 deletions(-) delete mode 100644 C4/LogStatic.pm diff --git a/C4/Context.pm b/C4/Context.pm index 88c8c00..fa39f40 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -102,7 +102,6 @@ use ZOOM; use XML::Simple; use C4::Boolean; use C4::Debug; -use C4::LogStatic qw/ logaction /; use Koha::Cache; use POSIX (); use DateTime::TimeZone; @@ -659,7 +658,6 @@ ON DUPLICATE KEY UPDATE value = VALUES(value)'; my $sth = $dbh->prepare($query); if ( $sth->execute(@params) ) { $syspref_cache->set_in_cache("syspref_$var", $value) if $use_syspref_cache; - logaction( $dbh, userenv(), 'SYSTEMPREFERENCE', $logtype, undef, $var . " | " . $value ); } $sth->finish; } @@ -684,8 +682,6 @@ sub delete_preference { my $res = $sth->execute($var); if ($res) { $syspref_cache->clear_from_cache("syspref_$var") if $use_syspref_cache; - logaction( $dbh, userenv(), 'SYSTEMPREFERENCE', 'DELETE', undef, - $var . " | " . ( $val // 'undefined' ) ); return 1; } warn "Unable to delete syspref: " . $sth->errstr; diff --git a/C4/LogStatic.pm b/C4/LogStatic.pm deleted file mode 100644 index 7cb1de2..0000000 --- a/C4/LogStatic.pm +++ /dev/null @@ -1,96 +0,0 @@ -package C4::LogStatic; - -# This is a very simple logging system, designed to be only used in -# circumstances where C4::Context can't be loaded. Typically, this is -# only in C4::Context itself. -# -# This is intended to be temporary until C4::Context gets refactored to not -# handle things like sysprefs that need logged about. - - -# Copyright 2000-2002 Katipo Communications -# Copyright 2011 MJ Ray and software.coop -# Copyright 2014 Catalyst IT -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use vars qw($VERSION @ISA @EXPORT); - -BEGIN { - # set the version for version checking - $VERSION = 3.07.00.049; - require Exporter; - @ISA = qw(Exporter); - @EXPORT = qw(&logaction); -} - -=head1 NAME - -C4::LogStatic - basic logging function for Koha. - -=head1 SYNOPSIS - - use C4::LogStatic; - logaction($dbh, $userenv, "module", "action", $objectnum, "what happened"); - -=head1 DESCRIPTION - -This allows simple logging in situtations where C4::Context can't be loaded. - -=head1 FUNCTIONS - -=over 2 - -=item logaction - - logaction($dbh, $userenv, $modulename, $actionname, $objectnumber, $infos); - -Adds a record into action_logs table to report the different changes upon the database. -Each log entry includes the number of the user currently logged in. For batch -jobs, which operate without authenticating a user and setting up a session, the user -number is set to 0, which is the same as the superlibrarian's number. - -=cut - -#' -sub logaction { - my ($dbh, $userenv, $modulename, $actionname, $objectnumber, $infos)=@_; - - # 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 $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0; - $usernumber ||= 0; - - my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info) values (now(),?,?,?,?,?)"); - $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos); - $sth->finish; -} - - -1; -__END__ - -=back - -=head1 AUTHOR - -Koha Development Team - -=cut -- 1.9.1