Question for the OXID developers

In “function __autoload( $sClass )” a class is directly loaded in

foreach ( $aClassDirs as $sDir ) {
    $sFilename = $sDir . strtolower( $sClass ) . '.php';
    if ( file_exists( $sFilename ) ) {

require_once $sFilename;
return;
}
}
if it is found in the directories searched:

        $aClassDirs = array( $sBasePath . 'core/',
                             $sBasePath . 'views/',
                             $sBasePath . 'core/exception/',
                             $sBasePath . 'core/interface/',
                             $sBasePath . 'admin/reports/',
                             $sBasePath . 'admin/',
                             $sBasePath . 'modules/',
                             $sBasePath
                            );

Without even checking, if an overload module exists later on like …

   // special case
    if ( !in_array( $sClass, $aTriedClasses ) && is_array(  $aModules = oxConfig::getInstance()->getConfigParam( 'aModules' ) ) )  {

My question is: why is it done that way???

Why not check every class for overloading modules???

Also: the "aModules"array (holding the information on class overloads) should be made available much earlier as it is done now!

I presume, that many more classes could be overloaded doing so, as it is possible now!

Nobody home???

This is interesting. When oxnew is used i think every class is already checked for modules in oxUtilsObject->getClassName( $sClassName ).
What is this “special case”, is it ever used?

[QUOTE=leofonic;29413]This is interesting. When oxnew is used i think every class is already checked for modules in oxUtilsObject->getClassName( $sClassName ).
What is this “special case”, is it ever used?[/QUOTE]
Yes, many times, to load classes which are used, but not yet explicitly loaded.

Just set a debugger breakpoint there, and look what happens…

Yes that’s what the whole class is used for, but i mean only the part after

//special case

[QUOTE=leofonic;29418]Yes that’s what the whole class is used for, but i mean only the part after

//special case

[/QUOTE]
Yes, I think so…

But the main question is: why isn’t that checked always?

Well every class is checked for overloading modules by the factory oxnew. The additional check in the autoloader looks like some superfluous code to me.

If the autoloader is invoked by PHP, some class is used, which has not been activated before by oxnew…

This is a list of classes beeing handled by the autoloader (in sequence of their invocation)…

oxUtils
oxSuperCfg
oxUtilsObject
oxConfig
oxUtilsFile
oxSession
oxUtilsServer
oxDb
oxStart
oxUBase
oxexceptionhandler
oxseodecoder
oxStr
oxstrregular
oxLang
oxStdClass
oxshopcontrol
alist
oxshop
oxI18n
oxBase
oxField
oxcmp_user
oxuser
oxcmp_lang
oxbasketitem
oxBasket
oxPrice
oxPriceList
oxcmp_cur
oxcmp_shop
oxcmp_categories
oxmanufacturerlist
oxList
oxmanufacturer
oxIUrl
oxUtilsCount
oxSeoEncoderManufacturer
oxSeoEncoder
oxcategorylist
oxcategory
oxUtilsDate
oxUtilsView
oxviewconfig
oxcontentlist
oxcontent
oxcmp_utils
oxcmp_news
oxcmp_basket
oxarticlelist
oxarticle
oxIArticle
oxactions
oxSeoEncoderCategory
oxrssfeed
oxDiscountList
oxdiscount
oxUtilsString
oxoutput
oxSeoEncoderContent
And this list contains quite some classes, I would love to overload

So, back to my question:

Why is there noch check for these classes, if they should be overloaded???

[QUOTE=avenger;29443]
[B]Why is there noch check for these classes, if they should be overloaded???[/B][/QUOTE]
But how should the autoloader do this? If you use “new oxarticle” you will always get an oxarticle object. Only when the factory is used: “oxnew(‘oxarticle’)” the factory will execute “new myoxarticle”.

Hi,
I think you don’t realize the __autoload purpose.
__autoload is called then the class is used in new statment (like $oObject = new oxActicle())
so if class will not be loaded, PHP will throw Fatal Error.
special case in this autoloader is used for creating modules parents if it is not created before.
so the flow is this:
$oObject = oxNew(‘oxlist’);
// finds the module for oxlist
// creates all parrents of oxlist modules
// calls __autoload to init the core/oxlist.php

[QUOTE=wanis;29476]
special case in this autoloader is used for creating modules parents if it is not created before.
[/QUOTE]
But how could this ever happen, module parent files are already included by oxnew?

[QUOTE=leofonic;29500]But how could this ever happen, module parent files are already included by oxnew?[/QUOTE]
Good point…

So the code there checking for overloads is simply superfluous…