Bug 11581

Summary: HTTP 404s generated badly in some cases
Product: Koha Reporter: Galen Charlton <gmcharlt>
Component: Architecture, internals, and plumbingAssignee: Galen Charlton <gmcharlt>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: dcook, fridolin.somers, katrin.fischer
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11612
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23329
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30261
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 10581    

Description Galen Charlton 2014-01-17 15:59:05 UTC
There are several scripts that do the following when they want to signal that a resource (usually a MARC record) does not exist:

    print $query->redirect("/cgi-bin/koha/errors/404.pl");

This is not great, because what actually happens is that an HTTP 302 redirect is issued, followed by the 404.  This wastes a bit of time for the user agent, and might be problematic if you let search engines crawl your OPAC.

Better would be doing 

   print $cgi->header( -status => '404 record not found');

or if a more specific message should be displayed, constructing it and calling

  output_with_http_headers $query, $cookie, $error_template->output, 'html', '404 Not Found';

The affected scripts are:

catalogue/showmarc.pl
opac/opac-ISBDdetail.pl
opac/opac-MARCdetail.pl
opac/opac-authoritiesdetail.pl
opac/opac-detail.pl
opac/opac-export.pl
opac/opac-showmarc.pl
opac/opac-topissues.pl
opac/tracklinks.pl
Comment 1 Fridolin Somers 2014-03-25 11:15:03 UTC
Indeed.
I think there should be HTML static pages for all HTTP error codes.
They should be used in both apache configuration and in GCI output (maybe adding methods into C4::Output).
Comment 2 David Cook 2022-03-10 03:38:44 UTC
With Bug 30261, we should be able to use C4::Output::output_error() for any staff interface or OPAC page.
Comment 3 David Cook 2022-03-10 03:40:14 UTC
(In reply to Fridolin Somers from comment #1)
> Indeed.
> I think there should be HTML static pages for all HTTP error codes.
> They should be used in both apache configuration and in GCI output (maybe
> adding methods into C4::Output).

I like the idea of static HTML pages.

I think we've avoided them because we want to use the templating and such for a common look and feel, but I was just thinking... we could generate the static HTML pages during an app build step. I suppose that wouldn't work well for a git deployment though...