Error page: don't link stylesheets that do not exist
Every error page requested /assets/css/branding-<BRAND>.css and /assets/css/style.css, and both 404'd: fitme3070 has no assets/css/ directory at all — the backoffice styles are inlined in includes/header.php. Cosmetic on its own, but actively misleading. Those two 404s are the loudest thing in the console at precisely the moment someone opens the console to find out what broke, and they read like the cause rather than a side effect of the error page rendering. They sent this investigation after the wrong file twice. Now each link is emitted only if the file is actually on disk, so a console on an error page shows the real failure and nothing else. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d40adbf64
commit
7097ccbe0b
1 file changed
+16
-5
@@ -57,12 +57,23 @@ function _error_page(string $title, string $detail, string $trace = ''): void {
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
<title>Erro — <?= htmlspecialchars(defined('APP_NAME') ? APP_NAME : 'Plataforma') ?></title>
|
<title>Erro — <?= htmlspecialchars(defined('APP_NAME') ? APP_NAME : 'Plataforma') ?></title>
|
||||||
<?php if ($cssBase):
|
<?php
|
||||||
$_eh_brand = (function_exists('env') ? env('BRAND', 'andmore') : 'andmore') ?: 'andmore';
|
// Only link stylesheets that actually exist. fitme3070 has no assets/css/ at
|
||||||
|
// all — its backoffice styles are inlined in includes/header.php — so these
|
||||||
|
// two links were guaranteed 404s on every error page. Harmless in themselves,
|
||||||
|
// but they are the loudest thing in the console at exactly the moment someone
|
||||||
|
// is reading the console to find out what broke, and they sent this
|
||||||
|
// investigation after the wrong file twice.
|
||||||
|
$_eh_brand = (function_exists('env') ? env('BRAND', 'andmore') : 'andmore') ?: 'andmore';
|
||||||
|
$_eh_css = [
|
||||||
|
'/assets/css/branding-' . $_eh_brand . '.css',
|
||||||
|
'/assets/css/style.css',
|
||||||
|
];
|
||||||
|
foreach ($_eh_css as $_eh_href):
|
||||||
|
if ($cssBase === '' || !is_file(dirname(__DIR__) . $_eh_href)) continue;
|
||||||
?>
|
?>
|
||||||
<link rel="stylesheet" href="<?= htmlspecialchars($cssBase) ?>/assets/css/branding-<?= htmlspecialchars($_eh_brand) ?>.css">
|
<link rel="stylesheet" href="<?= htmlspecialchars($cssBase . $_eh_href) ?>">
|
||||||
<link rel="stylesheet" href="<?= htmlspecialchars($cssBase) ?>/assets/css/style.css">
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
<style>
|
<style>
|
||||||
body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
|
body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
|
||||||
|
|||||||
Reference in new issue
Block a user