Fixed bug #9748: Some extensions do not work anymore in the frontend
authorOliver Hader <oliver.hader@typo3.org>
Wed, 12 Nov 2008 18:32:19 +0000 (18:32 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 12 Nov 2008 18:32:19 +0000 (18:32 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4458 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php

index 7197b8f..7c0aff5 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
        * Fixed bug #9747: Update function names of caching API to be consistent with FLOW3
        * Cleanup: Updated NEWS.txt
        * Added feature #9778: Improvement of removeXSS (thanks to Steffen Kamper, David Slayback)
+       * Fixed bug #9748: Some extensions do not work anymore in the frontend
 
 2008-11-11  Steffen Kamper  <info@sk-typo3.de>
 
index e5a4047..a9f915e 100755 (executable)
@@ -5984,7 +5984,8 @@ class tslib_cObj {
                $parts = explode('->',$funcName);
                if (count($parts)==2)   {       // Class
                        $cls = t3lib_div::makeInstanceClassName($parts[0]);
-                       if (class_exists ($cls))        {
+                               // Check whether class is available and try to reload includeLibs if possible:
+                       if ($this->isClassAvailable($cls, $conf)) {
                                $classObj = new $cls;
                                if (method_exists($classObj, $parts[1]))        {
                                        $classObj->cObj = &$this;
@@ -6393,6 +6394,38 @@ class tslib_cObj {
                return false;
        }
 
+       /**
+        * 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) {
+               if (class_exists($className)) {
+                       return true;
+               } else {
+                       $pluginConfiguration =& $GLOBALS['TSFE']->tmpl->setup['plugin.'][$className . '.'];
+                       if (isset($pluginConfiguration['includeLibs']) && $pluginConfiguration['includeLibs']) {
+                               $config['includeLibs'] = $pluginConfiguration['includeLibs'];
+                               return $this->includeLibs($config);
+                       }
+               }
+               return false;
+       }
+