Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@


RewriteRule ^robots.txt$ static/robots.txt [L]
RewriteRule ^F static/rewrite.php [L]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on the commit - fc3f2a4

RewriteRule ^cgi-bin/(.+)$ static/rewrite.php [L]

# Hold
RewriteRule ^(Record)/([^/]+)/(Hold)/(.+)$ index.php?module=$1&id=$2&action=$3&barcode=$4 [QSA,L]
Expand All @@ -63,6 +61,8 @@


RewriteRule ^([^/]+)/(.+)$ index.php?module=$1&action=$2 [QSA,L]

ErrorDocument 404 /index.php?module=Error&action=Error404
</IfModule>

# Disable Magic Quotes
Expand All @@ -72,6 +72,6 @@ php_value magic_quotes_gpc false
AddType application/x-httpd-php .css

## Uncomment these lines if you wish to show all errors on the screen.
php_value display_errors 1
php_value error_reporting 2047
# php_value display_errors 1
# php_value error_reporting 2047

2 changes: 0 additions & 2 deletions docker/nginx-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ server {


rewrite ^/robots.txt$ /static/robots.txt last;
rewrite ^/F /static/rewrite.php last;
rewrite ^/cgi-bin/(.+)$ /static/rewrite.php last;


# Hold
Expand Down
24 changes: 9 additions & 15 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
}
}


//################################
// HTStatus
//
Expand Down Expand Up @@ -312,10 +311,10 @@
$service = new $action();
$service->launch();
} else {
PEAR::raiseError(new PEAR_Error('Unknown Action'));
PEAR::raiseError(new PEAR_Error("Not found"));
}
} else {
PEAR::raiseError(new PEAR_Error("Cannot Load Action: module=$module, action=$action"));
PEAR::raiseError(new PEAR_Error("Not found"));
}


Expand All @@ -325,22 +324,17 @@

// Process any errors that are thrown
function handlePEARError($error, $method = null) {
$module = (isset($_GET['module'])) ? $_GET['module'] : 'Search';
$interface = new UInterface();
$interface->assign('error', $error);
$interface->assign('module', $module);
header('HTTP/1.1 404 Not Found');
// If the module was Bib API ("api") but the rewrite rules could not parse the URL
// then we could provide a developer error string in JSON form. For now, bail out.
$module = (isset($_GET['module'])) ? $_GET['module'] : 'error';

if ($module == 'api') {
header('HTTP/1.1 404 Not Found');
exit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be responsible for the Bib API 200s where there should be 404s.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should put a 404 and maybe JSON payload?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I'll check what it was doing before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've restored the behavior it had before, which was a bare 404.

}
$interface->setTemplate('error.tpl');
$interface->display('layout.tpl');

foreach ($error->backtrace as $trace) {
echo '[' . $trace['line'] . '] ' . $trace['file'] . '<br>';
}
require_once "services/Error/Error404.php";
$service = new Error404();
$service->launch();

exit();
}

Expand Down
29 changes: 29 additions & 0 deletions interface/themes/firebird/Error/Error404.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<hathi-cookie-consent-banner></hathi-cookie-consent-banner>
<ul id="skiplinks" class="visually-hidden-focusable" role="complementary" aria-label="Skip links">
<li>
<a href="#section">Skip to main</a>
</li>
</ul>
<div id="root">
{include file="header.tpl"}

<main class="main-container" id="main">
{include file="search_form.tpl"}

<div class="container container-medium flex-container flex-container-expanded container-boxed" style="margin-top: 1.75rem; margin-bottom: 1.75rem">

<section class="section-container" id="section">
<h1>
404 Not Found
</h1>

<p>
No page was found with that URL. Check the URL, or use the search bar above to explore HathiTrust.
</p>
</section>
</div>

</main>

{include file="footer.tpl"}
</div>
17 changes: 17 additions & 0 deletions services/Error/Error404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

class Error404 {

function launch() {

$interface = new UInterface();
header('HTTP/1.1 404 Not Found');
$interface->assign('module', 'Error');
$interface->setTemplate('Error404.tpl');
$interface->display('layout.tpl');

exit();
}
}

?>
2 changes: 1 addition & 1 deletion services/Record/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Record extends Action
public $cacheId;

public $db;

public $inTemp = false;
public $inSubset = false;
public $isFavorite = false;
Expand Down