Added feature #15075: [Install] make a pre-check for required php-extensions (Thanks...
authorXavier Perseguers <typo3@perseguers.ch>
Tue, 28 Sep 2010 11:06:27 +0000 (11:06 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Tue, 28 Sep 2010 11:06:27 +0000 (11:06 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8919 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/install/mod/class.tx_install.php

index 1add25e..df0879c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-28  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Added feature #15075: [Install] make a pre-check for required php-extensions (Thanks to Jigal van Hemert)
+
 2010-09-28  Steffen Kamper  <steffen@typo3.org>
 
        * Follow-up to #15812: Add backend maintenance for login news - added sprites for icon
index bb66306..743add3 100755 (executable)
@@ -231,6 +231,19 @@ class tx_install extends t3lib_install {
                'logout' => 'Logout from Install Tool',
        );
 
+               // PHP modules which are required. Can be changed by hook in getMissingPhpModules()
+       protected $requiredPhpModules = array(
+               'filter',
+               'gd',
+               'json',
+               'mysql',
+               'pcre',
+               'session',
+               'SPL',
+               'standard',
+               'xml',
+               'zlib'
+       );
 
 
 
@@ -254,6 +267,12 @@ class tx_install extends t3lib_install {
                        header('Pragma: no-cache');
                }
 
+                       // Let DBAL decide whether to load itself
+               $dbalLoaderFile = $this->backPath . 'sysext/dbal/class.tx_dbal_autoloader.php';
+               if (@is_file($dbalLoaderFile)) {
+                       include($dbalLoaderFile);
+               }
+
                        // ****************************
                        // Initializing incoming vars.
                        // ****************************
@@ -261,6 +280,18 @@ class tx_install extends t3lib_install {
                $this->mode = t3lib_div::_GP('mode');
                if ($this->mode !== '123') {
                        $this->mode = '';
+               } else {
+                               // Check for mandatory PHP modules
+                       $missingPhpModules = $this->getMissingPhpModules();
+                       if (count($missingPhpModules) > 0) {
+                               t3lib_BEfunc::typo3PrintError(
+                                       'TYPO3 Installation Error',
+                                       'The following PHP module(s) is/are missing: <em>' .
+                                               implode(', ', $missingPhpModules) .
+                                               '</em><br /><br />You need to install and enable these modules first to be able to install TYPO3.'
+                               );
+                               die();
+                       }
                }
                if (t3lib_div::_GP('step') === 'go') {
                        $this->step = 'go';
@@ -340,12 +371,6 @@ class tx_install extends t3lib_install {
                                @touch($enableInstallToolFile);
                        }
 
-                               // Let DBAL decide whether to load itself
-                       $dbalLoaderFile = $this->backPath . 'sysext/dbal/class.tx_dbal_autoloader.php';
-                       if (@is_file($dbalLoaderFile)) {
-                               include($dbalLoaderFile);
-                       }
-
                        if($this->redirect_url) {
                                t3lib_utility_Http::redirect($this->redirect_url);
                        }
@@ -4115,15 +4140,43 @@ REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndp
                return (is_array($test) ? 1 : 0);
        }
 
+       /**
+        * Checks if the essential PHP modules are loaded
+        *
+        * @return array list of modules which are missing
+        */
+       protected function getMissingPhpModules() {
 
-
-
-
-
-
-
-
-
+                       // Hook to adjust the required PHP modules in the 1-2-3 installer
+               $modules = $this->requiredPhpModules;
+               if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['requiredPhpModules'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['requiredPhpModules'] as $classData) {
+                               $hookObject = t3lib_div::getUserObj($classData);
+                               $modules = $hookObject->setRequiredPhpModules($modules, $this);
+                       }
+               }
+               $this->requiredPhpModules = $modules;
+               
+               $result = array();
+               foreach ($this->requiredPhpModules as $module) {
+                       if (is_array($module)) {
+                               $detectedSubmodules = FALSE;
+                               foreach ($module as $submodule) {
+                                       if (extension_loaded($submodule)) {
+                                               $detectedSubmodules = TRUE;
+                                       }
+                               }
+                               if ($detectedSubmodules === FALSE) {
+                                       $result[] = 'one of: (' . implode(', ', $module) . ')';
+                               }
+                       } else {
+                               if (!extension_loaded($module)) {
+                                       $result[] = $module;
+                               }
+                       }
+               }
+               return $result;
+       }
 
        /*****************************************
         *