Follow-up to feature #9633: Enabled autoloading in TYPO3 Core
authorOliver Hader <oliver.hader@typo3.org>
Tue, 19 May 2009 13:52:53 +0000 (13:52 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Tue, 19 May 2009 13:52:53 +0000 (13:52 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5449 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php
typo3/init.php
typo3/mod/tools/em/class.em_soap.php
typo3/mod/tools/em/class.em_terconnection.php
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_eidtools.php
typo3/sysext/cms/tslib/index_ts.php
typo3/sysext/cms/tslib/media/scripts/fe_adminLib.inc
typo3/sysext/indexed_search/class.crawler.php

index a97fd2d..eb19f7b 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2009-05-19  Oliver Hader  <oliver@typo3.org>
 
        * Added feature #9633: Implement autoloading for TYPO3
+       * Follow-up to feature #9633: Enabled autoloading in TYPO3 Core
 
 2009-05-19  Steffen Kamper  <info@sk-typo3.de>
 
index e198c77..aaf9dce 100644 (file)
@@ -4822,7 +4822,7 @@ final class t3lib_div {
        public static function makeInstanceClassName($className)        {
                self::logDeprecatedFunction();
 
-               return class_exists('ux_'.$className) ? t3lib_div::makeInstanceClassName('ux_'.$className) : $className;
+               return (class_exists('ux_'.$className, false) ? t3lib_div::makeInstanceClassName('ux_' . $className) : $className);
        }
 
        /**
@@ -4833,7 +4833,7 @@ final class t3lib_div {
         * @return      string          Final class name to instantiate with "new [classname]"
         */
        protected function getClassName($className) {
-               return class_exists('ux_' . $className) ? self::getClassName('ux_' . $className) : $className;
+               return (class_exists('ux_' . $className, false) ? self::getClassName('ux_' . $className) : $className);
        }
 
        /**
index b61a982..aefb941 100644 (file)
@@ -153,6 +153,14 @@ die();
        $temp_path_t3lib = @is_dir(PATH_site.'t3lib/') ? PATH_site.'t3lib/' : PATH_typo3.'t3lib/';
        define('PATH_t3lib', $temp_path_t3lib);                 // Abs. path to t3lib/ (general TYPO3 library) within the TYPO3 admin dir
        define('PATH_typo3conf', PATH_site.'typo3conf/');       // Abs. TYPO3 configuration path (local, not part of source)
+
+       if (!defined('PATH_tslib')) {
+               if (@is_dir(PATH_site . TYPO3_mainDir . 'sysext/cms/tslib/')) {
+                       define('PATH_tslib', PATH_site . TYPO3_mainDir . 'sysext/cms/tslib/');
+               } elseif (@is_dir(PATH_site . 'tslib/')) {
+                       define('PATH_tslib', PATH_site . 'tslib/');
+               }
+       }
 }
 
 
@@ -168,7 +176,14 @@ require_once(PATH_t3lib.'class.t3lib_extmgm.php'); // Extension API Management l
 require(PATH_t3lib.'config_default.php');
 if (!defined ('TYPO3_db'))     die ('The configuration file was not included.');
 
-require_once(PATH_t3lib.'class.t3lib_db.php');         // The database library
+
+// *********************
+// Autoloader
+// *********************
+require_once(PATH_t3lib . 'class.t3lib_autoloader.php');
+t3lib_autoloader::registerAutoloader();
+
+
 /** @var TYPO3_DB t3lib_db */
 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
 $TYPO3_DB->debugOutput = $TYPO3_CONF_VARS['SYS']['sqlDebug'];
index 0432a7c..404b611 100644 (file)
@@ -88,11 +88,12 @@ class em_soap {
                }
 
                if (!$options['implementation'] || $options['implementation'] == 'detect') {
+                               // Avoid autoloading, since it's only a strategy check here:
                        if (defined('SOAP_1_2')) {
                                $options['implementation'] = 'phpsoap';
-                       } elseif (class_exists('soapclient')) {
+                       } elseif (class_exists('soapclient', false)) {
                                $options['implementation'] = 'nusoap';
-                       } elseif (class_exists('SOAP_Client')) {
+                       } elseif (class_exists('SOAP_Client', false)) {
                                $options['implementation'] = 'pearsoap';
                        }
                }
index c28e2f6..120cb90 100644 (file)
@@ -298,7 +298,8 @@ class SC_mod_tools_em_terconnection {
 
                $filesData = array();
                foreach ($uArr['FILES'] as $filename => $infoArr) {
-                       $content = (!defined('SOAP_1_2') && class_exists('soapclient')) ? base64_encode($infoArr['content']) : $infoArr['content']; // bug in NuSOAP - no automatic encoding
+                               // Avoid autoloading "soapclient", since it's only a strategy check here:
+                       $content = (!defined('SOAP_1_2') && class_exists('soapclient', false)) ? base64_encode($infoArr['content']) : $infoArr['content']; // bug in NuSOAP - no automatic encoding
                        $filesData['fileData'][] = array (
                                'name' => utf8_encode($infoArr['name']),
                                'size' => intval($infoArr['size']),
index a9db221..7e7c794 100644 (file)
@@ -6061,8 +6061,8 @@ class tslib_cObj {
                $parts = explode('->',$funcName);
                if (count($parts)==2)   {       // Class
                        $cls = t3lib_div::makeInstanceClassName($parts[0]);
-                               // Check whether class is available and try to reload includeLibs if possible:
-                       if ($this->isClassAvailable($cls, $conf)) {
+                               // Check whether class is available:
+                       if (class_exists($cls)) {
                                $classObj = new $cls;
                                if (method_exists($classObj, $parts[1]))        {
                                        $classObj->cObj = &$this;
@@ -6474,37 +6474,6 @@ class tslib_cObj {
                return $librariesIncluded;
        }
 
-       /**
-        * Checks whether a PHP class is available. If the check fails, the method tries to
-        * determine the correct includeLibs to make the class available automatically.
-        *
-        * TypoScript example that can cause this:
-        * | plugin.tx_myext_pi1 = USER
-        * | plugin.tx_myext_pi1 {
-        * |   includeLibs = EXT:myext/pi1/class.tx_myext_pi1.php
-        * |   userFunc = tx_myext_pi1->main
-        * | }
-        * | 10 = USER
-        * | 10.userFunc = tx_myext_pi1->renderHeader
-        *
-        * @param       string          $className: The name of the PHP class to be checked
-        * @param       array           $config: TypoScript configuration (naturally of a USER or COA cObject)
-        * @return      boolean         Whether the class is available
-        * @link        http://bugs.typo3.org/view.php?id=9654
-        * @TODO        This method was introduced in TYPO3 4.3 and can be removed if the autoload was integrated
-        */
-       protected function isClassAvailable($className, array $config = NULL) {
-               if (class_exists($className)) {
-                       return true;
-               } elseif ($config) {
-                       $pluginConfiguration =& $GLOBALS['TSFE']->tmpl->setup['plugin.'][$className . '.'];
-                       if (isset($pluginConfiguration['includeLibs']) && $pluginConfiguration['includeLibs']) {
-                               $config['includeLibs'] = $pluginConfiguration['includeLibs'];
-                               return $this->includeLibs($config);
-                       }
-               }
-               return false;
-       }
 
 
 
index 7624680..b7bf80a 100644 (file)
@@ -117,7 +117,6 @@ final class tslib_eidtools {
        public static function initLanguage($language = 'default') {
                if (!is_object($GLOBALS['LANG'])) {
                        require_once(PATH_t3lib . 'class.t3lib_cs.php');
-                       require_once(t3lib_extMgm::extPath('lang', 'lang.php'));
                        $GLOBALS['LANG'] = t3lib_div::makeInstance('language');
                        $GLOBALS['LANG']->init($language);
                }
index cc6d5e3..7955065 100644 (file)
@@ -111,7 +111,16 @@ if (!defined('PATH_tslib')) {
        define('PATH_tslib', t3lib_extMgm::extPath('cms').'tslib/');
 }
 
-require_once(PATH_t3lib.'class.t3lib_db.php');
+
+// *********************
+// Autoloader
+// *********************
+$TT->push('Register Autoloader', '');
+       require_once(PATH_t3lib . 'class.t3lib_autoloader.php');
+       t3lib_autoloader::registerAutoloader();
+$TT->pull();
+
+
 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
 $TYPO3_DB->debugOutput = $TYPO3_CONF_VARS['SYS']['sqlDebug'];
 
@@ -331,7 +340,6 @@ $TT->pull();
 if ($TSFE->beUserLogin) {
        $BE_USER->initializeFrontendEdit();
        if ($BE_USER->frontendEdit instanceof t3lib_frontendedit) {
-               require_once(t3lib_extMgm::extPath('lang').'lang.php');
                $LANG = t3lib_div::makeInstance('language');
                $LANG->init($BE_USER->uc['lang']);
 
index 0680e31..6d6e4b1 100755 (executable)
@@ -1536,7 +1536,8 @@ class user_feAdmin        {
        function sendHTMLMail($content,$recipient,$dummy,$fromEmail,$fromName,$replyTo='')      {
                if (trim($recipient) && trim($content)) {
                        $cls=t3lib_div::makeInstanceClassName('t3lib_htmlmail');
-                       if (class_exists($cls)) {       // If htmlmail lib is included, then generate a nice HTML-email
+                               // Avoid autoloading of t3lib_htmlmail, since it's only a strategy check here:
+                       if (class_exists($cls, false))  {       // If htmlmail lib is included, then generate a nice HTML-email
                                $parts = spliti('<title>|</title>',$content,3);
                                $subject = trim($parts[1]) ? trim($parts[1]) : 'TYPO3 FE Admin message';
 
index e72da76..e64f8b9 100755 (executable)
@@ -70,7 +70,6 @@
 
 
 # To make sure the backend charset is available:
-require_once(PATH_typo3.'sysext/lang/lang.php');
 if (!is_object($GLOBALS['LANG']))      {
        $GLOBALS['LANG'] = t3lib_div::makeInstance('language');
        $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);