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?
thanks,
Demian