Bugzilla – Attachment 114554 Details for
Bug 24398
Error when viewing single news item and NewsAuthorDisplay pref set to OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24398: Fix 500 when viewing a single news item at the OPAC
Bug-24398-Fix-500-when-viewing-a-single-news-item-.patch (text/plain), 3.83 KB, created by
Nick Clemens (kidclamp)
on 2020-12-21 13:44:42 UTC
(
hide
)
Description:
Bug 24398: Fix 500 when viewing a single news item at the OPAC
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-12-21 13:44:42 UTC
Size:
3.83 KB
patch
obsolete
>From 319069c6e8df9a546f8a6f5b39afb4a44c4ba386 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 10 Dec 2020 15:10:10 +0100 >Subject: [PATCH] Bug 24398: Fix 500 when viewing a single news item at the > OPAC > >Test plan: >0. Set the NewsAuthorDisplay preference to 'OPAC' or 'Both OPAC and staff client.' >1. Open the OPAC main page and click on an individual news item >Without this patch you get an ugly 500 > Template process failed: undef error - The method Koha::NewsItem->author_title is not covered by tests! >With this patch applied you see the news with the author's info > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/NewsItem.pm | 8 +++++++- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 7 ++++++- > t/db_dependent/Koha/News.t | 9 ++++++++- > 3 files changed, 21 insertions(+), 3 deletions(-) > >diff --git a/Koha/NewsItem.pm b/Koha/NewsItem.pm >index c09f3f9d00..19bed767a6 100644 >--- a/Koha/NewsItem.pm >+++ b/Koha/NewsItem.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use Carp; > > use Koha::Database; >+use Koha::Patrons; > > use base qw(Koha::Object); > >@@ -37,7 +38,12 @@ Koha::NewsItem represents a single piece of news from the opac_news table > > =cut > >-=head3 type >+sub author { >+ my ( $self ) = @_; >+ return Koha::Patron->_new_from_dbic($self->_result->borrowernumber); >+} >+ >+=head3 _type > > =cut > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >index 3ee0709b3f..420a514bda 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -106,7 +106,12 @@ > <div class="newsfooter"> > Published on [% koha_new.published_on | $KohaDates %] > [% IF ( (newsdisp == 'opac' || newsdisp == 'both') && koha_new.borrowernumber ) %] >- by <span class="newsauthor_title">[% koha_new.author_title | html %] </span>[% koha_new.author_firstname | html %] [% koha_new.author_surname | html %] >+ [% IF news_item %] >+ [% SET author = koha_new.author %] >+ by <span class="newsauthor_title">[% author.title | html %] </span>[% author.firstname | html %] [% author.surname | html %] >+ [% ELSE %] >+ by <span class="newsauthor_title">[% koha_new.author_title | html %] </span>[% koha_new.author_firstname | html %] [% koha_new.author_surname | html %] >+ [% END %] > [% END %] > [% IF ( news_item ) %] > • <a href="/cgi-bin/koha/opac-main.pl">Show all news</a> >diff --git a/t/db_dependent/Koha/News.t b/t/db_dependent/Koha/News.t >index e1b56f5f3f..731a801a5c 100755 >--- a/t/db_dependent/Koha/News.t >+++ b/t/db_dependent/Koha/News.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > > use Koha::NewsItem; > use Koha::News; >@@ -54,5 +54,12 @@ is( $retrieved_news_item_1->content, $new_news_item_1->content, 'The content met > $retrieved_news_item_1->delete; > is( Koha::News->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' ); > >+subtest '->author' => sub { >+ plan tests => 1; >+ >+ my $news_item = $builder->build_object({ class => 'Koha::News' }); >+ is( ref($news_item->author), 'Koha::Patron', 'Koha::NewsItem->author returns a Koha::Patron object' ); >+}; >+ > $schema->storage->txn_rollback; > >-- >2.11.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 24398
:
114309
|
114312
|
114398
| 114554 |
114555