From a730a76069290be962e35fe034d713a77c662083 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 27 Mar 2023 11:53:45 +0000 Subject: [PATCH] Bug 18829: (follow-up) Return 404 when record cannot be loaded Signed-off-by: Tomas Cohen Arazi --- catalogue/showelastic.pl | 6 +++--- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/catalogue/showelastic.pl b/catalogue/showelastic.pl index 1b9318cc3a..6bbf569b64 100755 --- a/catalogue/showelastic.pl +++ b/catalogue/showelastic.pl @@ -31,8 +31,8 @@ use Try::Tiny; # Koha modules used use C4::Context; -use C4::Output; -use C4::Auth; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw(get_template_and_user); use C4::Biblio; use C4::ImportBatch; use C4::XSLT ; @@ -65,8 +65,8 @@ try { }); } catch{ - @es_fields = ("Error fetching record: see logs for details"); warn $_; + print $input->redirect("/cgi-bin/koha/errors/404.pl"); }; for my $field (sort keys %{$es_record} ){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 00be41b3c4..c43f70b3d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1738,7 +1738,11 @@ Note that permanent location is a code, and location may be an authval. $("body").on("click",".previewElastic", function(e){ e.preventDefault(); var pageElastic = $(this).attr("href"); - $("#elasticPreview .modal-body").load(pageElastic); + $("#elasticPreview .modal-body").load(pageElastic, function( response, status, xhr ) { + if( status == 'error' ){ + $("#elasticPreview .modal-body").html('

An error has occurred!

Error 404

  • An internal link in the client is broken and the page does not exist
  • What\'s next?

    '); + } + }); $('#elasticPreview').modal({show:true}); }); [% END %] -- 2.39.5