Top menu disappeared
| Symptom | |
| Root cause | |
| Fix | |
| Regression cover |
Symptom
Article and section pages rendered with zero <nav class="address"> blocks. Nothing in the page templates had changed.
Root cause
The shared breadcrumb lookup detects the section class with a get_declared_classes() diff around require_once:
$before = get_declared_classes();
require_once($RelatedArticlesUrl);
$new = array_values(array_diff(get_declared_classes(), $before));
if (empty($new)) { return ''; }
Every documented page pre-requires its section file, so the diff is always empty, the lookup always fails, and breadcrumbs silently return an empty string. The cleverness defeated its own documented usage pattern.
Fix
When the diff is empty, find the already-declared class by source file instead of giving up:
$ref = new \ReflectionClass($class);
if (realpath($ref->getFileName()) === realpath($url)
&& $ref->hasMethod('breadcrumbs')) { ... }
Applied in all three page classes. Same behavior for fresh requires, restored behavior for pre-required files.
Regression cover
The content suite accepts --tag address, which asserts <nav class="address"> instead of the bottom marker:
./scripts/run-check.sh --web --url https://testsetup.site --tag address
Article author: Andrei Olegovich
| Development with PHP | |
| PHP errors: case studies | |
| Top menu disappeared | |
| Live page truncated to 30 bytes | |
| Cannot redeclare get_urls() |