-
Notifications
You must be signed in to change notification settings - Fork 0
ETT-1189: Disable PHP error reporting in production; ETT-1140 show a styled 404 page #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,6 @@ | |
| } | ||
| } | ||
|
|
||
|
|
||
| //################################ | ||
| // HTStatus | ||
| // | ||
|
|
@@ -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")); | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should put a 404 and maybe JSON payload?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably. I'll check what it was doing before.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
| } | ||
|
|
||
|
|
||
| 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> |
| 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(); | ||
| } | ||
| } | ||
|
|
||
| ?> |
There was a problem hiding this comment.
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