[!!!][TASK] Remove class loading fallback in cObject 85/45085/7
authorBenni Mack <benni@typo3.org>
Wed, 2 Dec 2015 12:58:11 +0000 (13:58 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 24 Dec 2015 10:22:35 +0000 (11:22 +0100)
Remove cObj->isClassAvailable() as this class was
introduced in TYPO3 4.3 before autoloading was there.

Now, with TYPO3 CMS 7, autoloading is completely done
via spl_autoload_register and class_exists() does the
autoloading automatically, both in composer-mode and
non-composer-mode.

The method is therefore removed as the fallback is
pre-historic and a simple class_exists() check is added.

Resolves: #72022
Releases: master
Change-Id: I92eef8dee6277bcec63403dcf04e12955cb669f2
Reviewed-on: https://review.typo3.org/45085
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Documentation/Changelog/master/Breaking-72022-RemovedClassLoadingFallbackInCObject.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-72022-RemovedClassLoadingFallbackInCObject.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72022-RemovedClassLoadingFallbackInCObject.rst
new file mode 100644 (file)
index 0000000..7d55bb7
--- /dev/null
@@ -0,0 +1,20 @@
+============================================================
+Breaking: #72022 - Removed class loading fallback in cObject
+============================================================
+
+Description
+===========
+
+The method ``ContentObjectRenderer->isClassAvailable()`` was used internally to check for a TypoScript property
+``plugin.tx_myextension_pi1.includeLibs`` that included a PHP file when ``class_exists()`` failed.
+
+With TYPO3 CMS 7, the spl_autoload mechanism checks for all places within extensions, alternatively composer does this
+on build-time. All needed classes are known, making this check and the option obsolete.
+
+The functionality was introduced in TYPO3 4.3 before autoloading was available, and was now removed.
+
+
+Impact
+======
+
+The option .includeLibs on a plugin TypoScript object has no effect anymore.
index aa86a91..4d83003 100644 (file)
@@ -6693,9 +6693,8 @@ class ContentObjectRenderer
         // Split parts
         $parts = explode('->', $funcName);
         if (count($parts) === 2) {
-            // Class
-            // Check whether class is available and try to reload includeLibs if possible:
-            if ($this->isClassAvailable($parts[0], $conf)) {
+            // Check whether PHP class is available
+            if (class_exists($parts[0])) {
                 $classObj = GeneralUtility::makeInstance($parts[0]);
                 if (is_object($classObj) && method_exists($classObj, $parts[1])) {
                     $classObj->cObj = $this;
@@ -7073,40 +7072,6 @@ class ContentObjectRenderer
         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 bool Whether the class is available
-     * @link http://forge.typo3.org/issues/19510
-     * @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;
-        }
-        if ($config) {
-            $pluginConfiguration = &$this->getTypoScriptFrontendController()->tmpl->setup['plugin.'][$className . '.'];
-            if (isset($pluginConfiguration['includeLibs']) && $pluginConfiguration['includeLibs']) {
-                $config['includeLibs'] = $pluginConfiguration['includeLibs'];
-                return $this->includeLibs($config);
-            }
-        }
-        return false;
-    }
-
     /***********************************************
      *
      * Database functions, making of queries