Zend Framework

Zend_Loader_PluginLoader accepts duplicate prefix paths

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7.7
  • Fix Version/s: 1.9.3
  • Component/s: Zend_Loader
  • Labels:
    None

Description

Zend_Loader_PluginLoader::addPrefixPath has no check to ensure that the same path is not added multiple times per prefix. This issue can be inadvertently triggered by the following process:

1) Zend_Form is instantiated.
2) Zend_Form_SubForm is instantiated and set to use the same plugin loader as the form instance.
3) The subform instance is added to the form via Zend_Form::addSubForm, which implicitly adds all the form's loader's prefix paths to the subform (which adds them to the subform's loader, also the form's loader - and round and round we go).

The solution is to have Zend_Loader_PluginLoader::addPrefixPath check $this->_prefixToPaths[$prefix] for $path before adding it. Though I'm not entirely certain how or why it would have this effect, making this change removed a huge bottleneck in a Zend_Form-based class I dealt with recently and shaved the load time from 15 seconds to 5 seconds.

A patch to implement the change is attached. (I svn blame Ralph for this. )

  1. patch.diff
    26/Mar/09 1:02 PM
    0.7 kB
    Matthew Turland
  2. unittest.diff
    26/Mar/09 1:34 PM
    0.7 kB
    Matthew Turland

Activity

Hide
Matthew Turland added a comment -

Added unittest.diff which patches tests/Zend/Loader/PluginLoaderTest.php to add a test case for this patch.

Show
Matthew Turland added a comment - Added unittest.diff which patches tests/Zend/Loader/PluginLoaderTest.php to add a test case for this patch.
Hide
Benjamin Eberlei added a comment -

Patches by Matthew applied and tested, committed and merged into 1.9 release branch.

Show
Benjamin Eberlei added a comment - Patches by Matthew applied and tested, committed and merged into 1.9 release branch.

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: