ZF-6646: CLONE -Using Loader_Autoloader is not working on application with modules with similar names ( in action of a controller, please do not try in a simple test case)

Description

Hi,

I'm not sure if the problem is with Zend_Loader or Zend_Application (maybe other compoment), the problem is:

I use a modular application layout like this:

application/ config/ data/ ../ modules/ admin/ controllers/ models/ views/ ../ adminservices/ controllers/ models/ views/ ../ admintest/ adminxxx/ somename/ somenameetc/ module1/ module2/ module3/

As you can see I use modules with similar names, all modules use their Bootstrap so autoload works fine.. I can use models from any module BUT if found a problem for example:

If I try to load a model of module named "admin" from module "module1" or any other module it work OK. if I try to load a model of module named "adminservices" from any module it do not works, autoloader it not loading the class so I get a:

Fatal error: Class 'Adminservices_Model_XXXX' not found

I try with other modules and I can see that any modules that start with similar names autoloader only register the first one, so I can only call clases from admin, somename, etc, any other clases that start with this name it not working with autoloader..

Anyone can confirm this??? or I'm doing something wrong??

Thanks

Lyle

Comments

Please give a try on this: after install the test application check the url:

public/default/index/index

It will execute this code:

echo 'TEST START HERE: ' . '


';

echo 'Call model from default module:'. '
'; $modelo = new Default_Model_TestDefault(); echo $modelo->printName() . '

';

echo 'Call model from admin module:'. '
'; $modelo = new Admin_Model_TestAdmin(); echo $modelo->printName() . '

';

<<<< This will fail to load <<<

echo 'Call model from adminservices module:'. '
'; $modelo = new Adminservices_Model_TestAdminservices(); echo $modelo->printName() . '

';

DO NOT USE A PHPUnit_Framework_TestCase as a test case.. PLEASE TRY IN A REAL EXAMPLE, IN A ACTION OF A CONTROLLER LIKE the included in the attachment based on zend test application... module: default controller: index aciton: index

Anyone else can reproduce the problem???

This is a test based on the quickstart zend application, please reproduce the problem in the module default, controller index, action index.

That is how you can reproduce the problem.

Maybe related to this ZF-6484

http://framework.zend.com/issues/browse/ZF-6484

Please attach some simple code with which this can be tested. Currently there's a zipfile attached containing a huge amount of files, besides the fact that this is probably way overkill, there's also no mention at all (that I can see) of how to actually get the errors you're getting.

The .zip file is the same quickstart application of zend framework tutorial page, this include some models (to test the problem) from different named application modules. To test (reproduce the problem):

  • just copy the latest zend library to the /library
  • try the /public directory, the test code is in the default module, index controller, index view..

-- CODE --

    echo 'TEST START HERE: ' . '<br /><br /><br />';
    echo 'Call model from default module:'. '<br />';
    $modelo = new Default_Model_TestDefault();
    echo $modelo->printName() . '<br /><br />';

    echo 'Call model from admin module:'. '<br />';
    $modelo = new Admin_Model_TestAdmin();
    echo $modelo->printName() . '<br /><br />';

    echo 'Call model from adminservices module:'. '<br />';
    $modelo = new Adminservices_Model_TestAdminservices();
    echo $modelo->printName() . '<br /><br />';

-- CODE --

if you try a simple model test case it will not reproduce the problem, you need to try from a controller action.

The problem will raise if you try to call a model Adminservices_Model_TestAdminservices, I think Loader is not working it stop when find the model Admin_Model_TestAdmin.

The test application will output this:

TEST START HERE:

Call model from default module: Default_Model_TestDefault

Call model from admin module: Admin_Model_TestAdmin

Call model from adminservices module:

Fatal error: Class 'Adminservices_Model_TestAdminservices' not found in D:\www\quickstart\application\controllers\IndexController.php on line 47

This works for me in 1.11. Closing as cannot reproduce.