Wednesday, June 13, 2012

Strange PHP5.3 require_once bug

It started yesterday, a strange production bug which made a page unavailable to the end-user. The project I work on has a very nifty bug catching feature that just outputs a blank page whenever a 500 error happen (which makes it soooo easy to debug). So I roll-up my sleeves and ssh on the production server and start browsing this haystack of logs we keep. There I find the source of this ugly 500: PHP Fatal error: require_once(): failed opening required '/opt/www/model/app.mailgnp.php' in /opt/www/view/mailform.php line 10 (yes we have an ugly app). Ok, so there must be a typo of some sort. Opening mailform.php, what do I find on line 10? require_once '/opt/www/model/app.mailgrp.php';

Yes indeed, '/opt/www/model/app.mailgrp.php' exists and '/opt/www/model/app.mailgnp.php' doesn't. So why in the world PHP is trying to load a file that doesn't exist instead of the one that's written in the statement??

Replacing require_once with include fixed the bug, and now I'm left with a fixed bug but no clue about why it happened and a strange feeling of a coming doom (I cannot safely rely anymore on what looked like a perfectly Cartesian process).

Paris Clem: now lost in a sea of uncertainty

No comments: