View Issue Details

IDProjectCategoryView StatusLast Update
0005011OXID eShop (all versions)4.10. AutoLoaderpublic2013-03-22 13:56
Reporteralberthorta Assigned To 
PriorityurgentSeverityblockReproducibilityalways
Status resolvedResolutionwon't fix 
PlatformPHP 5.3.8 - OXID PE 4.7.3_54408OSLinuxOS Version2.6.32.46-0.3-pa
Product Version4.7.3 / 5.0.3 revision 54408 
Summary0005011: Problem overloading non custom classes
DescriptionWhen you try to extend a php base class like (by example) SphinxClient in oxutilsobject.php line 436 :

                       class_alias($sParentClass, $sModuleParentClass);

Fails if $sParentClass it's not user defined function. This restriction is not documented on php documentation (http://php.net/manual/en/function.class-alias.php) but I got this warning:

Warning: First argument of class_alias() must be a name of user defined class in XXXXXXXXXXXX/core/oxutilsobject.php on line 436

Besides of the warning, the class it's not aliased so, everything ends in a Fatal Error like this:

Fatal error: Class 'myclass_parent' not found in XXXXXXXXXXXX/modules/mymodule/core/myclass.php on line 1

The fix I applied is replace line 436 for:


                        $oReflection = new ReflectionClass($sParentClass);
                        if(!$oReflection->isUserDefined()) {
                            eval("abstract class $sModuleParentClass extends $sParentClass {}");
                        } else {
                            class_alias($sParentClass, $sModuleParentClass);
                        }
Steps To Reproducetry to overload a non user defined class on your module and add the line to do it on your metadata.php (extend) and try to onNew the class.
Additional InformationOnly happens on (PHP 5 >= 5.3.0)
TagsNo tags attached.
ThemeBoth
BrowserAll
PHP Version5.3
Database Versionany

Activities

Linas Kukulskis

2013-03-22 12:26

reporter   ~0008526

its not best practice to extend standard classes with oxNew mechanism. first extend standard class by your defined class and then use in code, in modules.