[dev] Fwd: include vs include_once in Horde_Autoloader

Michael Rubinsky mrubinsk at horde.org
Wed Aug 5 00:35:03 UTC 2009


Quoting Michael M Slusarz <slusarz at horde.org>:

> Quoting Michael Rubinsky <mrubinsk at horde.org>:
>
>> Quoting Michael M Slusarz <slusarz at horde.org>:
>>
>>> Quoting Michael Rubinsky <mrubinsk at horde.org>:
>>>
>>>>> Horde_Autoloader::addClassPattern('/^' . $app . '[$_]/i', $app_lib);
>>>>
>>>> This results in the application's base class not being loadable.  
>>>> i.e. Kronolith::
>>>
>>> Why not?  Oh, square brackets only match characters, not special  
>>> pattern.  D'oh.  This should be correct:
>>>
>>> Horde_Autoloader::addClassPattern('/^' . $app . '(?:$|_)/i', $app_lib);
>>>
>>> Sure enough, it works:
>>>
>>> preg_match('/^kronolith(?:$|_)/i', 'Kronolith_Test', $matches);
>>> print_r($matches);
>>> Array
>>> (
>>>   [0] => Kronolith_
>>> )
>>>
>>>
>>> preg_match('/^kronolith(?:$|_)/i', 'Kronolith', $matches);
>>> print_r($matches);
>>> Array
>>> (
>>>   [0] => Kronolith
>>> )
>>
>> Nope. Still broken. The issue is that kronolith/lib is never put on  
>> the include path if the addClassPath() call is removed. If it's  
>> left in, then the original problem still exists.
>
> II think the issue is that we should avoid using addClassPath() for  
> applications.  Instead, we should directly include files in  
> applications only if it matches a string from addClassPattern().  If  
> the classname doesn't match any class pattern, only then do a final  
> include that tries to load from any of the directories in  
> include_path.
>
> I've uploaded changes to an 'autoload' branch in horde-git.  Try  
> pulling that commit and see if it works for you.

Works great. Thanks!


Thanks,
mike

--
The Horde Project (www.horde.org)
mrubinsk at horde.org

"Time just hates me. That's why it made me an adult." - Josh Joplin


More information about the dev mailing list