When OPcache Strikes Back: Fixing Blank Pages and Chasing Phantom Bugs
Had one of those debugging sessions today that reminded me why I love and hate web development in equal measure. The iv-hydration site went completely blank, and what started as a simple fix turned into a three-headed monster of string/array confusion and caching nightmares.
The Great Blank Page Mystery
The site was throwing a fatal error, and after some digging, I found the culprit: bbs_get_section('services') was returning a string instead of an array, but my code was happily trying to run array_map() on it. Classic PHP move.
The fix was straightforward enough - just added some is_array() guards in seo.php and the home page template. Should be simple, right?
Plot Twist: OPcache Had Other Plans
Here's where it gets fun. I made the fixes, refreshed the page, and... still broken. Made more changes, still broken. Started questioning my entire existence as a developer.
Turns out PHP-FPM had OPcache enabled with 2,851 cached scripts, and it was completely ignoring my file changes. The web server was happily serving up the old broken code while I'm over here editing files like a maniac.
Had to create a quick opcache-reset-tmp.php endpoint, hit it via HTTP to flush the cache, then immediately delete it. Suddenly everything worked perfectly. 200 OK, 131KB full page, beautiful schema markup - the works.
Lessons Learned (Again)
A few things I'm definitely remembering for next time:
- OPcache on Cloudways FPM is totally separate from CLI. File edits won't show up until you flush via an HTTP endpoint.
- Always guard your array operations.
bbs_get_section()can return strings, arrays, or probably carrier pigeons depending on the phase of the moon. - Test with real requests. The internal Varnish test was giving me wrong results due to cross-site cache hits.
curl --compressedis your friend.
What's Next
The site is back up and running, but there are still some quirky data issues to clean up. The company name is showing as "Luminary MedSpa & Wellness" in some places but "Pure Drip Wellness" in the database. Plus there are literal quotes around "Miami" in the title tag, which is... not ideal.
Going to dig into the DCC data next and figure out where these inconsistencies are coming from. Sometimes I think the most challenging part of development isn't writing new code - it's debugging the mysteries that existing code leaves behind.
Anyone else have those days where a simple fix turns into an archaeological expedition through your own codebase? Just me? Cool.