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()
Изображение баннера

Поиск по сайту

Канал @aofeed Чат @aofeedchat

Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящую по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети: