Hi guys, I've been debugging a zf app for the best part of the weekend and a 
couple of questions.

Through debugging I noticed Zend_Loader was checking paths with the ZendX
prefix. The app wasn't isn't using any ZendX components. All
Zend_Application resources are being checked with the ZendX prefix first
*then* the Zend prefix. This should be other way round? 

On investigating I found:

(1.11.11) lines 415 - 427 - Zend_Application_Bootstrap_BootstrapAbstract
   public function getPluginLoader()
    {
        if ($this->_pluginLoader === null) {
            $options = array(
                'Zend_Application_Resource'  => 'Zend/Application/Resource',
                'ZendX_Application_Resource' => 'ZendX/Application/Resource'
            );

            $this->_pluginLoader = new Zend_Loader_PluginLoader($options);
        }

        return $this->_pluginLoader;
    }

I'm guessing it's LIFO. 

To test it I overide that method in my app bootstrap and reordered the
options:

$options = array(
    'ZendX_Application_Resource' => 'ZendX/Application/Resource',
    'Zend_Application_Resource'  => 'Zend/Application/Resource'
);

with that, everything works fine with less file reads, for example
Zend_Loader::isReadable() was being called ~64 times before and ~56 times
after the change (in one sample). That doesn't seem like a lot but then
::isReadable() actually loops through the include_path and calls
is_readable() a number of times for each path until it finds the file. So,
on the same sample counting the is_readable() calls inside
Zend_Loader::isReadable yeilded ~269 calls before and 222 after. 

I didn't do any benchmarks so I don't really know how much of performance
hit this is, I can't imagine it's good and besides it was easy just to
override the plugin loader and save a few cycles.

Before I file this as a bug, is this a bug or expected behaviour? It seems
senseless for ZendX paths to checked for files, i thought ZendX was opt-in.

Thanks in advance.

To test the behaviour:

zf create project .
vi ./library/ZendX/Application/Resource/Frontcontroller.php

<?php
class ZendX_Application_Resource_Frontcontroller extends
Zend_Application_Resource_ResourceAbstract
{
    public function init()
    {
        throw new LogicException("ZendX FrontController Application Resource
says \"I'm first!\"");
    }
}


--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Application-check-for-ZendX-Application-Resources-first-even-though-my-app-isn-t-using-ZendX-bu-tp4341432p4341432.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to