I’m running into an extremely strange bug using ZF 2.2.1 and PHP 5.3.6.
To make a long story short, under a very specific set of circumstances, Zend\ServiceManager\ServiceManager seems to be corrupting its instances property.
I ran into a bug where I was getting the wrong object returned by a ->get() call, and after a bit of code tracing, I determined that the wrong object was coming from the ServiceManager’s instances array…
I added some debug output to ServiceManager, so every place that sets a value into instances dumps out:
echo 'setting ' . $cName . ' to ' . (is_object($instance) ? get_class($instance) : 'non-object') . '<br />';
…and everything retrieving from the array dumps out:
echo 'returning ' . get_class($this->instances[$cName]) . ' for ' . $cName . "<br />";
For the offending service, my output contains:
setting resource to VuFind\Db\Table\Resource
returning VuFind\Record\Loader for resource
There is no reference to the resource service in between! So how is it changing class? There is no code outside of ServiceManager that manipulates instances, and I made the property private to rule out subclass interference. Same results!
I can’t reproduce this problem on a different server running a newer version of PHP, so I’m suspicious that it’s some kind of crazy PHP internal problem… but I thought I’d mention the situation here before I start upgrading PHP in desperation, just in case it rings a bell! Anyone else seen anything like this? Am I overlooking something important in the way SM works?
Can you make a gist of what the issue is? I honestly didn't understand what is going on...
On 6 August 2013 21:09, Demian Katz <[hidden email]> wrote:
Unfortunately, right now the setup I need to reproduce the bug is so complicated that I’m not sure how to reduce it to a simpler case – any advice on how to narrow this down would be welcome (the problem boils down to one object getting set to $this->instances[$cName] and a different object getting returned with no apparent resetting in between… but that makes so little sense that I’m not sure how to even analyze what’s going on!)
In reply to this post by Marco Pivetta
A quick update:
Since this was so difficult to track down, I decided to try upgrading PHP to see if my theory of a low-level problem was correct. Sure enough, moving from PHP 5.3.6 to PHP 5.3.27 solved the problem. I wish I could provide more information to explain what was going on, but the best I can say is that a large application with multiple service managers seems prone to problems with PHP 5.3.6 – in addition to the bizarre behavior I described, I was also seeing intermittent segmentation faults.
|Free forum by Nabble||Edit this page|