Bug 10352: Display the correct modification logs for bibliographic records
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 13 May 2019 15:36:14 +0000 (10:36 -0500)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 10 Jan 2020 08:30:10 +0000 (08:30 +0000)
The 'Modification log" link in the cataloguing module returns confusing
results. The 'object' parameter is the biblionumber, but the all log
from itemnumber=biblionumber will be displayed as well.
Since bug 11473 we have the action_logs.info column that is prefixed by
'item ' or 'biblio ' to disociated an item modification from a biblio
modif.
This patch suggests a quick and dirty approach, use this column to make
sure we are searching for the correct logs.
/!\ As bug 11473 did not update the existing rows, we will no longer display
the logs created prior to this change.

Test plan:
Make sure you have at least 2 bibliographic records with some items
Make sure you have the biblionumbers of those records that match
existing itemnumbers
Edit them (no matter what you change)
Go to the bibliographic detail page (staff) and click "Modification log"
You should see the correct changes.

Signed-off-by: hc <hc@interleaf.ie>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

tools/viewlog.pl

index f8463c0..40e1c66 100755 (executable)
@@ -132,10 +132,21 @@ if ($do_it) {
     $search_params{user} = $user if $user;
     $search_params{module} = { -in => [ @modules ] } if ( defined $modules[0] and $modules[0] ne '' ) ;
     $search_params{action} = { -in => [ @actions ] } if ( defined $actions[0] && $actions[0] ne '' );
-    $search_params{object} = $object if $object;
-    $search_params{info} = $info if $info;
     $search_params{interface} = { -in => [ @interfaces ] } if ( defined $interfaces[0] && $interfaces[0] ne '' );
 
+
+    if ( @modules == 1 && $modules[0] eq 'CATALOGUING' ) {
+        # Handle 'Modification log' from cataloguing
+        my @itemnumbers = Koha::Items->search({ biblionumber => $object })->get_column('itemnumber');
+        $search_params{'-or'} = [
+            { -and => { object => $object, info => { -like => 'biblio %' }}},
+            { -and => { object => \@itemnumbers, info => { -like => 'item %' }}},
+        ];
+    } else {
+        $search_params{info} = $info if $info;
+        $search_params{object} = $object if $object;
+    }
+
     my @logs = Koha::ActionLogs->search(\%search_params);
 
     my @data;