+3
−3
Loading
DOCUMENT_ROOT is not a stable string across the contexts that share one
Bitrix installation, so deriving the memcached sid from it silently splits
the cache into several namespaces:
- nginx passes the `root` directive verbatim, trailing slash included,
while cron_events.php builds its own DOCUMENT_ROOT via realpath(),
which strips it — web and cron end up on different prefixes;
- multisite on one core serves several document roots, so each site
gets its own namespace despite sharing a DB and a bitrix/ folder.
Managed-cache invalidation then never reaches the other contexts. The
visible symptom on refcat.frostpost.ru was the mail queue: CEvent's drain
loop caches an "events pending queue is empty" flag under CACHED_b_event
(main/lib/mail/eventmanager.php:33,138), which defaults to 3600s when
undefined (main/include/constants.php:42). Mail\Event::send() clears that
flag on enqueue, but from the web namespace, so cron kept skipping the
drain until the TTL expired — outbound mail batched on a 61 minute cycle
(3600s TTL plus one cron tick) instead of going out within a minute.
dirname() normalises the trailing slash and collapses every document root
of an installation onto one prefix. DOC_ROOT_NAME guarantees the document
root is always a subdirectory of the project root, so the result stays
unique per project.
Session keyPrefix is deliberately left on DOCUMENT_ROOT: sessions never
cross into CLI and are already namespaced by the cookie, so it has neither
the same failure mode nor the same fix, and changing it logs every user out.
Co-Authored-By:
Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CHsy6Jt7jVc73VzZuWw6gJ