From b5cfe3e20e8a39dd83457ad34e78f5d2df143c70 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 12 Jan 2024 08:44:12 +0100 Subject: [PATCH] Bug 35782: Replace TT plugin's method Biblio::HoldsCount We can use biblio.holds.count instead. The main idea here is to make sure we are passing a Koha::Biblio object as 'biblio' to all the templates including biblio-view-menu.inc Test plan: 1. Go to the biblio detail view, click on the different entries in the menu on the left. Confirm that the "Holds" tab always has the correct number of Holds display in the parenthesis. 2. Run a search and confirm that the number of holds are still displayed for each result. QA: git grep biblio-view-menu.inc notice the tt list, open the corresponding perl controllers and confirm that 'biblio' is passed and that it is a Koha::Biblio object. The only missing place I found was in viewlog. Note that we are not removing the TT method yet, we are marking it as deprecated and also display a warning during the update DB process in case one of the notice templates is using it. Signed-off-by: David Nind --- Koha/Template/Plugin/Biblio.pm | 3 +++ .../data/mysql/atomicupdate/bug_35782.pl | 25 +++++++++++++++++++ .../prog/en/includes/biblio-view-menu.inc | 4 +-- .../prog/en/modules/catalogue/results.tt | 4 +-- .../prog/en/modules/reserve/request.tt | 2 +- tools/viewlog.pl | 4 ++- 6 files changed, 36 insertions(+), 6 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35782.pl diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm index 79c7284292..d23eb094b6 100644 --- a/Koha/Template/Plugin/Biblio.pm +++ b/Koha/Template/Plugin/Biblio.pm @@ -31,9 +31,12 @@ use Koha::Recalls; use Koha::DateUtils qw(dt_from_string); +# Do not use HoldsCount, it is deprecated and will be removed in a future release. sub HoldsCount { my ( $self, $biblionumber ) = @_; + warn "HoldsCount is deprecated, you should use biblio.holds.count instead"; + my $holds = Koha::Holds->search( { biblionumber => $biblionumber } ); return $holds->count(); diff --git a/installer/data/mysql/atomicupdate/bug_35782.pl b/installer/data/mysql/atomicupdate/bug_35782.pl new file mode 100755 index 0000000000..a2d0bcedd9 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35782.pl @@ -0,0 +1,25 @@ +use Modern::Perl; + +return { + bug_number => "BUG_35872", + description => "Biblio.HoldsCount is deprecated", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + my ($count) = $dbh->selectrow_array( + q{ + SELECT COUNT(*) + FROM letter + WHERE content LIKE "%Biblio.HoldsCount%"; + } + ); + + if ($count) { + say $out "WARNING - Biblio.HoldsCount is used in at least one notice template"; + say $out "It is deprecated and will be remove in a future version of Koha."; + say $out "Replace it with biblio.holds.count instead"; + } + }, +}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 7d3aee9462..c7fbc727e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -1,6 +1,6 @@ [% USE Koha %] [% USE Biblio %] -[% SET biblio_object_id = object || biblionumber || biblio.biblionumber %] +[% SET biblio_object_id = biblio.biblionumber %]