From 7ceb9988e935165163a720d265f50646969c55de Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Tue, 22 Jan 2013 14:46:38 +0100 Subject: [PATCH 1/4] Bug 7241: circulation action logs record biblionumber instead of item number Issue log and and circulation logs are incorrectly recording biblionumber instead of item number, creating incorrect logs. This patch corrects this, and modifies the action_logs table in two ways: - the timestamp is not updated anymore with UPDATES (but still automatically filled when INSERTing) - to partially correct the broken logs, the log history is filled with the first found item for each biblio Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Signed-off-by: Jared Camins-Esakov --- C4/Circulation.pm | 4 ++-- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 05b5b7e42d..b5a5172de1 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1317,7 +1317,7 @@ sub AddIssue { } } - logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $biblio->{'biblionumber'}) + logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $biblio->{'itemnumber'}) if C4::Context->preference("IssueLog"); } return ($datedue); # not necessarily the same as when it came in! @@ -1885,7 +1885,7 @@ sub AddReturn { }); } - logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'biblionumber'}) + logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'}) if C4::Context->preference("ReturnLog"); # FIXME: make this comment intelligible. diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c74c39bbc5..2909dcd470 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2524,7 +2524,7 @@ CREATE TABLE `accountoffsets` ( DROP TABLE IF EXISTS `action_logs`; CREATE TABLE `action_logs` ( -- logs of actions taken in Koha (requires that the logs be turned on) `action_id` int(11) NOT NULL auto_increment, -- unique identifier for each action - `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time the action took place + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- the date and time the action took place `user` int(11) NOT NULL default 0, -- the staff member who performed the action (borrowers.borrowernumber) `module` text, -- the module this action was taken against `action` text, -- the action (includes things like DELETED, ADDED, MODIFY, etc) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index caa1fc523c..5e10670294 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6661,6 +6661,14 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.11.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;"); + $dbh->do("UPDATE action_logs SET info=(SELECT itemnumber FROM items WHERE biblionumber= action_logs.info LIMIT 1) WHERE module='CIRCULATION' AND action in ('ISSUE','RETURN');"); + print "Upgrade to $DBversion done (Bug 7241: Changing timestamp autoupdate on action_logs; setting items to circulation logs where missing)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS From a252e417fb24054c447c97fbbb8df9338126be46 Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Thu, 21 Mar 2013 14:30:46 +0100 Subject: [PATCH 2/4] Bug 7241 follow-up: DB changes Reset timestamp modification on update after patch application. Give more information about the log history fix. Signed-off-by: Marcel de Rooy Signed-off-by: Jared Camins-Esakov --- installer/data/mysql/kohastructure.sql | 2 +- installer/data/mysql/updatedatabase.pl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 2909dcd470..c74c39bbc5 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2524,7 +2524,7 @@ CREATE TABLE `accountoffsets` ( DROP TABLE IF EXISTS `action_logs`; CREATE TABLE `action_logs` ( -- logs of actions taken in Koha (requires that the logs be turned on) `action_id` int(11) NOT NULL auto_increment, -- unique identifier for each action - `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- the date and time the action took place + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time the action took place `user` int(11) NOT NULL default 0, -- the staff member who performed the action (borrowers.borrowernumber) `module` text, -- the module this action was taken against `action` text, -- the action (includes things like DELETED, ADDED, MODIFY, etc) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5e10670294..dc144dd4b9 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6665,7 +6665,9 @@ $DBversion = "3.11.00.XXX"; if ( CheckVersion($DBversion) ) { $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;"); $dbh->do("UPDATE action_logs SET info=(SELECT itemnumber FROM items WHERE biblionumber= action_logs.info LIMIT 1) WHERE module='CIRCULATION' AND action in ('ISSUE','RETURN');"); - print "Upgrade to $DBversion done (Bug 7241: Changing timestamp autoupdate on action_logs; setting items to circulation logs where missing)\n"; + $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;"); + print "Upgrade to $DBversion done (Bug 7241: Fix on circulation logs)\n"; + print "WARNING about bug 7241: to partially correct the broken logs, the log history is filled with the first found item for each biblio.\n"; SetVersion($DBversion); } From 520a82a754c1cc3f1b3747dc762aaef45d641ed3 Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Thu, 21 Mar 2013 16:05:27 +0100 Subject: [PATCH 3/4] Bug 7241, follow-up: viewlog link for circulation Fixes a few things about the CIRC link in viewlogs: - "itemnumber=" instead of "item=" - anchor #item was filled with the wrong field - tooltip now indicates "item" instead of "biblio" Signed-off-by: Adrien Saurat Signed-off-by: Jared Camins-Esakov --- koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index 1f42f530f7..a1d6e89fe4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -168,7 +168,7 @@ [% IF ( loopro.CIRCULATION ) %] - Item [% loopro.barcode |html %] + Item [% loopro.barcode |html %] [% ELSE %] [% loopro.info |html %] [% END %] From 7f8369dc2f937db6c4a5f588567f53a447733222 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Thu, 21 Mar 2013 11:44:08 -0400 Subject: [PATCH 4/4] Bug 7241: Increment version number Database update for bug 7241 has been given version 3.11.00.108 --- installer/data/mysql/updatedatabase.pl | 2 +- kohaversion.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index dc144dd4b9..8ce6a00d77 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6661,7 +6661,7 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } -$DBversion = "3.11.00.XXX"; +$DBversion = "3.11.00.108"; if ( CheckVersion($DBversion) ) { $dbh->do("ALTER TABLE action_logs CHANGE timestamp timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;"); $dbh->do("UPDATE action_logs SET info=(SELECT itemnumber FROM items WHERE biblionumber= action_logs.info LIMIT 1) WHERE module='CIRCULATION' AND action in ('ISSUE','RETURN');"); diff --git a/kohaversion.pl b/kohaversion.pl index dc828591a0..d9bdb74bab 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts : use strict; sub kohaversion { - our $VERSION = '3.11.00.107'; + our $VERSION = '3.11.00.108'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install