ZF-4697: Bug in PluginLoader breaks two Zend_View UnitTests


The two view tests that it breaks are

ViewTests.php -> testGetHelperPath() and testGetFilterPath()

The problem comes in with this code in the PluginLoader load() Method

if (class_exists($className, false)) {
    $found = true;

With the break it takes it out of the loop and never creates the $loadFile variable which sets the path to the class.

If you comment out this if statement everything is fine..


Attached is the patch to fix this. If you want me to fix it then I will.

BTW It produces one unit tests error and one unit tests failure now:

{panel} 8) testGetHelperPath(Zend_ViewTest) strpos(): Empty delimiter {panel}

{panel} 12) testGetFilterPath(Zend_ViewTest) Failed asserting that two strings are equal. expected string </home/cawa/ZendFramework/svn/framework/trunk/tests/Zend/View/_stubs/FilterDir1/Foo.php> difference <??????????????????????????????????????????????????????????????????????????????????????> got string <> {panel}

This appears to be resolved in current trunk.

OK I found how this bug is being produced.

If you call a helper by doing $mhc = new My_Helpers_Custom() before calling it from the helperBroker it produces the error.

I'm going to setup a test page and submit it for testing.

Update to remove the Fix Version since this is not fixed.

All unit tests for Zend_View are running fine currently. What OS, PHP version, and ZF version are you seeing the issue on?


This issue was submitted almost a year ago and I don't think it's valid any more. I forget what version of PHP I ran this on but it was for the 1.7.0 PR release.

I think this can be closed an a Non-Issue.

Found a test case that shows the bug. Also created a patch to correct it. Will attach patch next.

Patch: - adds a unit test for this issue - uses reflection to get which path the class was loaded from if it is already loaded

I'm reluctant to use this patch, as Reflection introduces substantial overhead -- and with something used as widely as the PluginLoader, this will have a lot of impact. In looking at your test case and patch, I discovered that we already have the code you describe: in getClassPath(). Since this is a method only used on-demand (not in every request), it makes sense to simply leverage this. Once I looked at that, I realized that I found the flaw: it was in how the $loadFile was detected and cached. I simply removed the logic to cache that information, and subsequently all tests, including your new one, pass.

Patch applied (with revisions) to trunk and 1.10 release branch.

The changes made to the PluginLoader make my application crash Apache. I can't really point my finger on it but if add a simple isset() there is no problem :S

        if ($this->_useStaticRegistry) {
            self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]     = $className;
        } else {
            $this->_loadedPlugins[$name]     = $className;

Any thoughts?

@Hendri Actually, no thoughts. The lines you quote were never changed. I actually simply modified the load() method not to store the class filename; instead, it's only retrieved on-demand when you use getClassFile().

Can you provide a reproduce case that demonstrates the behavior? The ZF site itself is using 1.10.2, and we're not experiencing any crashes at this time.

@Matthew There was probably something wrong with my Apache installation