Issues

ZF-2533: Zend internally doesn't use user-defined class loader

Issue Type: Bug Created: 2008-01-31T02:24:55.000+0000 Last Updated: 2009-05-14T05:44:06.000+0000 Status: Resolved Fix version(s): - 1.8.2 (27/May/09)

Reporter: Tomá? Procházka (t.prochazka) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Loader

Related issues: - ZF-3151

Attachments: - patch

Description

Zend own internally doesn't use my own class loader.

I set this:

<pre class="highlight">
MyZendLoader::registerAutoload('MyZendLoader');

And now for example in Zend_Db_Table_Row_Abstract is used this:

<pre class="highlight">
Zend_Loader::loadClass($tableClass);

But this static method is hardcoded and doesn't use my class loader, but table class it's my own class and I need use own class loader for it.

I found simple workarounfd, but it's necessary modify Zend_loader class and I don't like it.

<pre class="highlight">
    public static function loadClass($class, $dirs = null)
    {
        if (class_exists($class, false) || interface_exists($class, false)) {
            return;
        }
        
        if (spl_autoload_functions()!==false) {
          spl_autoload_call($class);
          if (class_exists($class, false) || interface_exists($class, false))  return;
        } 

I only add

<pre class="highlight">
        if (spl_autoload_functions()!==false) {
          spl_autoload_call($class);
          if (class_exists($class, false) || interface_exists($class, false))  return;
        } 

If is defined autoload function, Zend_Loader::loadClass() use it instead of default implementation.

Comments

Posted by Wil Sinclair (wil) on 2008-02-20T15:48:47.000+0000

Resetting priority and assigning for review.

Posted by Giorgio Sironi (giorgiosironi) on 2008-04-21T14:24:46.000+0000

As of 1.5.1 the issue remains unresolved. This is my patch proposal. It will add an optional argument to Zend_Loader::loadClass() to specify whether to use autoload. *_Loader should call the method specifying false as third argument, while calls to Zend_Loader::loadClass() from Zend_Db component now works.

Posted by Matthew Weier O'Phinney (matthew) on 2008-11-22T09:07:58.000+0000

This is a pretty major change, and has wide ranging implications -- performance, class resolution, etc. While I can see the benefits, we cannot make a change of this scope until we are ready for a major revision (2.0).

Posted by Andrea Ercolino (aercolino) on 2008-11-25T02:07:57.000+0000

I'm using the simple non-optional patch by Tomáš Procházka since march 2008 and it works pretty well. My setup is mixed: some classes follow ZF naming convention and some don't. The patch, together with my own class loader, makes any difference transparent.

As for the "wide ranging implications" I've seen none.

Posted by Wil Sinclair (wil) on 2008-12-30T06:41:07.000+0000

Assigning this to Matthew, as he oversees cross-cutting issues like this. I'd like to see a simple one-line comment that says with no uncertainty what we'll be doing- either wait for 2.0 or consider for 1.x.

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-14T05:44:06.000+0000

Resolved in trunk and 1.8 release branch

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts