PHP Exception Problems and eAccelerator 0.9.5.1-3 on FC7

Just before the Christmas break, I installed eAccelerator on our development servers in order to run some benchmark tests on the effects of code caching. As with many a pre-holiday project, I eventualy ran out of time, and promptly forgot that the caching was still up and running when I got back to work today.

Lo and behold, we had a strange problem with exception handling in our project code today. Exceptions we knew should be caught were causing fatal errors. I popped on to the php.net web site and grabbed the following example for a 'noddy' test script to run on the server.

function inverse($x) {
if (!$x) {
throw new Exception('Division by zero.');
}
else return 1/$x;
}

try {
echo inverse(5) . "\n";
echo inverse(0) . "\n";
} catch (Exception $e) {
echo 'Caught exception: '$e->getMessage(), "\n";
}

// Continue execution
echo 'Hello World';

So it ran and I got the following:

0.2
Fatal error: Uncaught exception 'Exception' with message 'Division by zero.'
in /var/www/development/dev1/test/general/trycatch2.php:4 Stack trace:
#0 /var/www/development/dev1/test/general/trycatch2.php(11): inverse(0)
#1 {main} thrown in /var/www/development/dev1/test/general/trycatch2.php on line 4

Not so good... so I googled about a bit and found reference to a problem that may be being caused by eAccelerator here.

I decided to try a little test. I edited the file at /etc/php.d/eaccelerator.ini and changed the line eaccelerator.enable="1" to eaccelerator.enable="0" in order to turn the caching off.

I restarted the server, re-ran the noddy script and got...

0.2 Caught exception: Division by zero. Hello World

... which I was happy about. So it seems that there is a bit of a problem with eAccelerator version 0.9.5.1-3 at the moment. Unfortunately we are stuck with that version until the FC7 version gets updated through yum - either that, or I'll upgrade the server to Fedora core version 8!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blogmarks
  • co.mments
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • Spurl
  • TailRank
  • YahooMyWeb

About this entry