Live page truncated to 30 bytes
| Symptom | |
| Ruled out | |
| Root cause | |
| Fix |
Symptom
A page returned HTTP 200 with a 30-byte body on hosting while the same page rendered fully locally. Error display is off on hosting, so the browser showed a silent truncation instead of the fatal.
Ruled out
- Stale files: a probe reporting md5_file() of every involved class proved all 8 hashes identical to the repo.
- OPcache: a probe running opcache_invalidate() on 12 files reported success — the page still truncated.
Root cause
src/.php is a symlink to src/ao/.php locally (one inode), but the FTP deploy resolves symlinks into two real directories. One page loaded the same helper through both spellings, and require_once — which dedupes by path, not by inode across machines — loaded it twice:
Fatal error: Cannot redeclare get_urls()
Unreproducible locally by design: the two paths can never diverge while linked.
Fix
Guard the definition so the second load is a no-op:
if (!function_exists('get_urls')) {
function get_urls(...$numbers)
{ ... }
} // function_exists('get_urls')
The hosting error log named file and line outright — it is always the first place to look. A repo-wide scan found 9 files requiring their own twin path; 8 were commented out, only this one executed.
Article author: Andrei Olegovich
| Development with PHP | |
| PHP errors: case studies | |
| Top menu disappeared | |
| Live page truncated to 30 bytes | |
| Cannot redeclare get_urls() |