[BUGFIX] Avoid PHP parse errors by PHP version check 66/36266/6
authorHelmut Hummel <helmut.hummel@typo3.org>
Mon, 26 Jan 2015 14:40:01 +0000 (15:40 +0100)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Mon, 26 Jan 2015 17:02:57 +0000 (18:02 +0100)
Display a proper error message if the PHP version 5.5 requirement is
not fulfilled instead of a fatal error "unexpected 'class' (T_CLASS)"
which might not even be displayed depending on server configuration.

Resolves: #64504
Releases: master
Change-Id: I04ae67e7fde645ff3a157192b437eae50041b6f9
Reviewed-on: http://review.typo3.org/36266
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
index.php
typo3/sysext/install/Resources/Private/PHP/Boot.php [new file with mode: 0644]
typo3/sysext/install/Start/Install.php

index 6a9222b..fcacf5d 100644 (file)
--- a/index.php
+++ b/index.php
  * delivered pages goes to in the frontend (the website)
  */
 
+/*
+ * This check avoids a parse error "unexpected 'class'" for users installing TYPO3 CMS 7
+ * on PHP 5.4. Without it the redirect to the install tool does not work.
+ * @see https://forge.typo3.org/issues/64504
+ */
+if (version_compare(PHP_VERSION, '5.5.0', '<')) {
+       die('TYPO3 CMS requires PHP 5.5 or above');
+}
+
 define('TYPO3_MODE', 'FE');
 
 require __DIR__ . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
diff --git a/typo3/sysext/install/Resources/Private/PHP/Boot.php b/typo3/sysext/install/Resources/Private/PHP/Boot.php
new file mode 100644 (file)
index 0000000..4029796
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+namespace TYPO3\CMS\Install;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+defined('TYPO3_MODE') or die();
+
+// Bootstrap bare minimum: class loader, LocalConfiguration, but no extensions and such
+require __DIR__ . '/../../../../core/Classes/Core/Bootstrap.php';
+\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
+       ->baseSetup('typo3/sysext/install/Start/')
+       ->startOutputBuffering()
+       ->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class);
+
+// Execute 'tool' or 'step' controller depending on install[controller] GET/POST parameter
+$getPost = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('install');
+$controllerClassName = \TYPO3\CMS\Install\Controller\StepController::class;
+if (isset($getPost['controller'])) {
+       switch ($getPost['controller']) {
+               case 'tool':
+                       $controllerClassName = \TYPO3\CMS\Install\Controller\ToolController::class;
+                       break;
+               case 'ajax':
+                       $controllerClassName = \TYPO3\CMS\Install\Controller\AjaxController::class;
+                       break;
+       }
+}
+\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($controllerClassName)->execute();
\ No newline at end of file
index 61ab6c3..a014cfe 100644 (file)
  *   can exist yet.
  */
 
+/*
+ * This check avoids a parse error "unexpected 'class'" for users installing TYPO3 CMS 7
+ * on PHP 5.4. Without it the redirect to the install tool does not work.
+ * @see https://forge.typo3.org/issues/64504
+ */
 if (version_compare(PHP_VERSION, '5.5.0', '<')) {
        die('TYPO3 CMS requires PHP 5.5 or above');
 }
@@ -100,24 +105,9 @@ if (version_compare(PHP_VERSION, '5.5.0', '<')) {
 define('TYPO3_MODE', 'BE');
 define('TYPO3_enterInstallScript', '1');
 
-// Bootstrap bare minimum: class loader, LocalConfiguration, but no extensions and such
-require __DIR__ . '/../../core/Classes/Core/Bootstrap.php';
-\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
-       ->baseSetup('typo3/sysext/install/Start/')
-       ->startOutputBuffering()
-       ->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class);
+/*
+ * The following functionality must be required from another file, otherwise a parse error
+ * "unexpected 'class'" will be shown on PHP 5.4 instead of the die() from version_compare above.
+ */
+require __DIR__ . '/../Resources/Private/PHP/Boot.php';
 
-// Execute 'tool' or 'step' controller depending on install[controller] GET/POST parameter
-$getPost = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('install');
-$controllerClassName = \TYPO3\CMS\Install\Controller\StepController::class;
-if (isset($getPost['controller'])) {
-       switch ($getPost['controller']) {
-               case 'tool':
-                       $controllerClassName = \TYPO3\CMS\Install\Controller\ToolController::class;
-                       break;
-               case 'ajax':
-                       $controllerClassName = \TYPO3\CMS\Install\Controller\AjaxController::class;
-                       break;
-       }
-}
-\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($controllerClassName)->execute();