Bugzilla – Attachment 161036 Details for
Bug 35782
Remove Koha::Template::Plugin::Biblio::HoldsCount
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35782: Replace TT plugin's method Biblio::HoldsCount
Bug-35782-Replace-TT-plugins-method-BiblioHoldsCou.patch (text/plain), 8.17 KB, created by
Tomás Cohen Arazi
on 2024-01-15 13:11:22 UTC
(
hide
)
Description:
Bug 35782: Replace TT plugin's method Biblio::HoldsCount
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2024-01-15 13:11:22 UTC
Size:
8.17 KB
patch
obsolete
>From 5a8718a97c7e99ac573ee48000d36a4c4b3e52a7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >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 <david@davidnind.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > 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 79c7284292f..d23eb094b65 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 00000000000..a2d0bcedd97 >--- /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 7d3aee94621..c7fbc727e8a 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 %] > > <div id="menu"> > <ul> >@@ -66,7 +66,7 @@ > [%- ELSE -%] > <li> > [%- END -%] >- <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio_object_id | url %]">Holds ([% Biblio.HoldsCount( biblio_object_id ) | html %])</a> >+ <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblio_object_id | url %]">Holds ([% biblio.holds.count | html %])</a> > </li> > [%- END -%] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index b6966286d43..1b5dd336da1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -562,11 +562,11 @@ > <span class="noholdstext">No holds allowed</span> > [% ELSE %] > [% IF CAN_user_reserveforothers_place_holds %] >- <a id="reserve_[% SEARCH_RESULT.biblionumber | html %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]">Holds ([% Biblio.HoldsCount( SEARCH_RESULT.biblionumber ) | html %])</a> >+ <a id="reserve_[% SEARCH_RESULT.biblionumber | html %]" href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]">Holds ([% SEARCH_RESULT.biblio_object.holds.count | html %])</a> > [% IF ( holdfor ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]&findborrower=[% holdfor_patron.cardnumber | uri %]">Place hold for [% INCLUDE 'patron-title.inc' patron => holdfor_patron no_title => 1 no_cardnumber => 1 %]</a></span>[% END %] > [% IF ( holdforclub ) %] <span class="holdforlink">| <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]&club=[% holdforclub | uri %]">Place hold for [% holdforclub_name | html %]</a></span>[% END %] > [% ELSE %] >- <span>Holds ([% Biblio.HoldsCount( SEARCH_RESULT.biblionumber ) | html %])</span> >+ <span>Holds ([% SEARCH_RESULT.biblio_object.holds.count | html %])</span> > [% END %] > [% END # /IF SEARCH_RESULT.norequests %] > [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index c29439bf01a..8d512eede75 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1041,7 +1041,7 @@ > > [% UNLESS ( patron ) %] > [% UNLESS borrowers %] >- [% SET hold_count = Biblio.HoldsCount( biblio.biblionumber ) | html %] >+ [% SET hold_count = biblio.holds.count | html %] > [% IF hold_count %] > <label for ="always_show_holds">Always show holds</label> > [% IF always_show_holds == 'DONT' %] >diff --git a/tools/viewlog.pl b/tools/viewlog.pl >index 9db4e430ed5..b6707b712c5 100755 >--- a/tools/viewlog.pl >+++ b/tools/viewlog.pl >@@ -130,11 +130,13 @@ if ($do_it) { > > if ( @modules == 1 && $object_type eq 'biblio' ) { > # Handle 'Modification log' from cataloguing >- my @itemnumbers = Koha::Items->search({ biblionumber => $object })->get_column('itemnumber'); >+ my $biblio = Koha::Biblios->find( $object ); >+ my @itemnumbers = $biblio->items->get_column('itemnumber'); > $search_params{'-or'} = [ > { -and => { object => $object, info => { -like => 'biblio%' }}}, > { -and => { object => \@itemnumbers, info => { -like => 'item%' }}}, > ]; >+ $template->param( biblio => $biblio ); > } else { > $search_params{info} = { -like => '%' . $info . '%' } if $info; > $search_params{object} = $object if $object; >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35782
:
160898
|
160930
|
160969
|
160987
|
160988
| 161036 |
161037