using spl_autoload instead of __autoload

Author Message

Douglas Hammond

Friday 15 August 2008 7:03:21 am

I was trying to use some services from the Zend frame work and ran into autoload conflicts.

To resolve it I changed ezPublish to register is autoloader with spl_autoload_register in /autoload.php.

I also had to apply the fix stated in http://issues.ez.no/10728

Now I have no problems with the autoloader of both frameworks.

I would suggest using spl_autoload_register instead of __autoload to become the default for interoperability.

 

function __ezPublish_spl_autoload( $className )
{
    static $ezpClasses = null;
    if ( is_null( $ezpClasses ) )
    {
        $ezpKernelClasses = require 'autoload/ezp_kernel.php';
        $ezpExtensionClasses = require 'autoload/ezp_extension.php';
        $ezpClasses = array_merge( $ezpKernelClasses, $ezpExtensionClasses );
    }

    if ( array_key_exists( $className, $ezpClasses ) )
    {
        require( $ezpClasses[$className] );
    }
    elseif ( EZCBASE_ENABLED )
    {
        ezcBase::autoload( $className );
    }
}

spl_autoload_register('__ezPublish_spl_autoload');

 

André R.

Sunday 17 August 2008 7:25:46 am

http://issues.ez.no/IssueView.php?Id=12862&

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 14:51:48
Script start
Timing: Jan 18 2025 14:51:48
Module start 'layout'
Timing: Jan 18 2025 14:51:48
Module start 'content'
Timing: Jan 18 2025 14:51:49
Module end 'content'
Timing: Jan 18 2025 14:51:49
Script end

Main resources:

Total runtime1.2715 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.1797152.6406
Module start 'layout' 0.00580.0030 741.820339.4766
Module start 'content' 0.00881.2614 781.2969523.6172
Module end 'content' 1.27020.0013 1,304.91418.1406
Script end 1.2715  1,313.0547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2596160.0002
Check MTime0.00130.1037160.0001
Mysql Total
Database connection0.00060.045610.0006
Mysqli_queries1.230696.7812540.0228
Looping result0.00050.0365520.0000
Template Total1.241897.720.6209
Template load0.00230.180020.0011
Template processing1.239597.482920.6198
Template load and register function0.00010.008710.0001
states
state_id_array0.00080.062710.0008
state_identifier_array0.00070.055120.0004
Override
Cache load0.00190.1479130.0001
Sytem overhead
Fetch class attribute can translate value0.00070.052120.0003
Fetch class attribute name0.00090.069030.0003
XML
Image XML parsing0.00040.034320.0002
class_abstraction
Instantiating content class attribute0.00000.003130.0000
General
dbfile0.00060.0510170.0000
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 8
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs