[BUGFIX] Fix early calls to makeInstance
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 25 Nov 2012 15:41:03 +0000 (16:41 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 25 Nov 2012 17:28:43 +0000 (18:28 +0100)
In case of an early call to makeInstance
the object configuration might not be set.

We can fix this by not calling makeInstance to
create the configuration manager and just
return the original class in that case.

Fixes: #43290
Related: #43269
Releases: 6.0

Change-Id: I30d9c70f2fda9dd6df6aad60a5ae5327c1fc3c52
Reviewed-on: http://review.typo3.org/16730
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 6f1559a..0cfba70 100644 (file)
@@ -133,7 +133,12 @@ class Bootstrap {
         */
        public function populateLocalConfiguration() {
                try {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->exportConfiguration();
+                       // We need an early instance of the configuration manager.
+                       // Since makeInstance relies on the object configuration, we create it here with new instead
+                       // and register it as singleton instance for later use.
+                       $configuarationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager', $configuarationManager);
+                       $configuarationManager->exportConfiguration();
                } catch (\Exception $e) {
                        die($e->getMessage());
                }
index f2ebbfd..af8d518 100644 (file)
@@ -4199,6 +4199,11 @@ Connection: close
         * @return boolean
         */
        static protected function classHasImplementation($className) {
+               // If we are early in the bootstrap, the configuration might not yet be present
+               if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'])) {
+                       return FALSE;
+               }
+
                return array_key_exists($className, $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'])
                                && is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$className])
                                && !empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$className]['className']);