6

We have been working on a project for several months without any problems until a set of recent updates. The server is running Amazon Linux AMI release 2010.11.1, with Apache 2.2.16 and PHP 5.3.3. The project is divided into a few separate developer branches, running as virtual hosts, each with a completely separate copy of all the code including Zend Framework 1.11.3. The project also includes Doctrine 2.0.1, but I don't think that is where the problem is. I have experimented with APC in the past, but I don't even have it installed right now. The issue seems to occur the most when multiple users are hitting the server across different branches. I suspect that the issue could be related to differing versions of certain core classes that are required during the Zend Framework bootstrap process, but I can't figure out what the root cause is. We have tried forcing all the branches to be at the same version from our git repo, and then restarted Apache. This temporarily resolves the issue, but it soon returns. It all began a week ago when I merely installed a set of mainstream updates for Linux, PHP, and Zend Framework. When the issue is occurring, it even propagates into our phpmyadmin virtual host, which doesn't even have anything to do with Zend Framework. I am stumped. Following is the set of errors we see in the Apache log:

[Wed Mar 02 20:32:40 2011] [error] [client 127.0.0.1] PHP Warning:  array_keys() expects parameter 1 to be array, null given in /var/www/dev/library/Zend/Loader/Autoloader.php on line 251, referer: https://foo.bar/admin/asset_manage/search
[Wed Mar 02 20:32:40 2011] [error] [client 127.0.0.1] PHP Warning:  Invalid argument supplied for foreach() in /var/www/dev/library/Zend/Loader/Autoloader.php on line 345, referer: https://foo.bar/admin/asset_manage/search
[Wed Mar 02 20:32:40 2011] [error] [client 127.0.0.1] PHP Warning:  array_key_exists() expects parameter 2 to be array, null given in /var/www/dev/library/Zend/Loader/Autoloader.php on line 194, referer: https://foo.bar/admin/asset_manage/search
[Wed Mar 02 20:32:40 2011] [error] [client 127.0.0.1] PHP Fatal error:  Class 'Zend_Config_Ini' not found in /var/www/dev/library/Zend/Application.php on line 383, referer: https://foo.bar/admin/asset_manage/search
LeeF
  • 111
  • 5
  • This is a related question: http://stackoverflow.com/questions/4188125/non-deterministic-object-reference-bug-in-php-5-3-x – Tim Wardle Jul 01 '11 at 13:29

3 Answers3

5

Well, after much agony over this issue, it turns out the problem was caused by a change in the behavior of the php realpath_cache. When I set realpath_cache_ttl = 0 in my php.ini, the issue with the improperly loading classes goes away.

I am not sure how this got introduced in these updates, but I don't think the cache is required on a dev box, so this gets me back on track. On a production server, I should only have one instance of the app running per Apache server anyway (no virtual hosts), so I could probably use the cache in that scenario.

If anyone has any additional insight into the cause of the realpath_cache issue, I wouldn't mind hearing it.

LeeF
  • 111
  • 5
  • 1
    I feel quite lonely here... maybe I'll have better luck next time. – LeeF Mar 04 '11 at 21:55
  • We just started noticing this problem in our application over the past two weeks. Our error logs show that has been happening consistently for at least 5 weeks. Your `realpath_cache_ttl=0` does the trick for us, too. In the interest of solving the problem correctly, I did some more research and found [this article](http://files.zend.com/help/Zend-Server/configuring_php_for_performance.htm) on Zend Server default PHP settings, and notice their realpath default cache size is 256K vs the 16K default on our CentOS 6.2 PHP 5.3.3 config. Trying a larger 1M cache with TTL at 120 again... – Joey T Feb 02 '12 at 18:45
  • 1
    Raising the realpath cache size to 1M helped, but only for a few hours, and then the autoloader errors started showing up again, so we turned realpath_cache_ttl=0 and that fixed it for about a day, then the errors show up again intermittently! It seems when they show up they occur for 20-30 minutes and then go away altogether. Like others have noticed at the same time this error appears, other same-system PHP applications like PHP MyAdmin also exhibit strange behavior. Still no real solution for this problem yet! – Joey T Feb 08 '12 at 20:31
3

This is a bug in PHP 5.3.2 (see https://bugs.php.net/bug.php?id=52083 and https://bugs.php.net/bug.php?id=50027). The bug is fixed in PHP 5.3.3.

Tim Wardle
  • 1,723
  • 1
  • 14
  • 14
0

We had the same problem with a similar server setup - a PHP app using Zend Framework 1.11.1 and Doctrine 2 running on nginx with php-fpm on a Ubuntu instance on the Amazon cloud. After restarting php-fpm, the problem seems to have gone away.

donalmacanri
  • 126
  • 2