N°3253 Fix setup crashing on incompatible PHP versions (#178)

We now have a new setup landing page. The old one is renamed setup/wizard.php

This contains revert for "🐛 Fix setup homepage error with PHP < 7.1.0" (91c6916d86) => it was one of the modifications that caused the setup to crash before this !
This commit is contained in:
Pierre Goiffon
2020-12-04 18:28:39 +01:00
committed by GitHub
parent 13d2699011
commit 70efa37109
3 changed files with 121 additions and 35 deletions

View File

@@ -1,6 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>iTop Setup - redirection</title>
<link type="text/css" href="../css/setup.css" rel="stylesheet">
</head>
<body>
<?php
/**
* Copyright (C) 2013-2019 Combodo SARL
/*
* Copyright (C) 2010-2020 Combodo SARL
*
* This file is part of iTop.
*
@@ -17,42 +24,57 @@
* You should have received a copy of the GNU Affero General Public License
*/
$bBypassMaintenance = true; // Reset maintenance mode in case of problem
/**
* Simple redirection page
* Will display an error message if a parse error occurs !
*
* @since 3.0.0 N°3253
*/
require_once('../approot.inc.php');
require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT.'/core/config.class.inc.php');
require_once(APPROOT.'/setup/setuppage.class.inc.php');
require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
clearstatcache(); // Make sure we know what we are doing !
// Set a long (at least 4 minutes) execution time for the setup to avoid timeouts during this phase
ini_set('max_execution_time', max(240, ini_get('max_execution_time')));
// While running the setup it is desirable to see any error that may happen
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
date_default_timezone_set('Europe/Paris'); // Just to avoid a warning if the timezone is not set in php.ini
SetupUtils::ExitMaintenanceMode(false);
echo <<<'HTML'
<script src="../js/jquery.min.js"></script>
<script>
bSkipErrorDisplay = false;
$(document).ready(function () {
if (!bSkipErrorDisplay) {
var $pageBody = $("body");
// $pageBody.addClass("error-container");
$pageBody.append("<div id='ibo-page-container'>" +
"<h1>😭 iTop cannot install</h1>" +
"<p class=\"message message-error\">💣 PHP version isn't compatible</p>" +
"<p>Please check <a href=\"https://www.itophub.io/wiki/page?id=latest%3Ainstall%3Ainstalling_itop#software_requirements\" target=\"_blank\">iTop requirements</a></p>" +
"</div>")
}
});
</script>
HTML;
/////////////////////////////////////////////////////////////////////
// Fake functions to protect the first run of the installer
// in case the PHP JSON module is not installed...
if (!function_exists('json_encode'))
function HandlePageErrors()
{
function json_encode($value, $options = null)
{
return '[]';
$error = error_get_last();
if ($error
&& (isset($error['type']))
&& (in_array($error['type'], [E_ERROR, E_PARSE, E_COMPILE_ERROR], true))) {
ob_end_clean();
}
}
if (!function_exists('json_decode'))
{
function json_decode($json, $assoc=null)
{
return array();
}
}
/////////////////////////////////////////////////////////////////////
$oWizard = new WizardController('WizStepWelcome');
$oWizard->Run();
register_shutdown_function('HandlePageErrors');
ob_start();
require_once("wizard.php");
ob_end_clean();
//echo <<<HTML
//<script>
//bSkipErrorDisplay = true;
//document.location = "wizard.php";
//</script>
//HTML;
?>
</body>
</html>

64
setup/wizard.php Normal file
View File

@@ -0,0 +1,64 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
/**
* This is not the index.php page as we need to check for any PHP parse error first !
*
* @see N°3253
*/
$bBypassMaintenance = true; // Reset maintenance mode in case of problem
require_once('../approot.inc.php');
require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT.'/core/config.class.inc.php');
require_once(APPROOT.'/setup/setuppage.class.inc.php');
require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
clearstatcache(); // Make sure we know what we are doing !
// Set a long (at least 4 minutes) execution time for the setup to avoid timeouts during this phase
ini_set('max_execution_time', max(240, ini_get('max_execution_time')));
// While running the setup it is desirable to see any error that may happen
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
date_default_timezone_set('Europe/Paris'); // Just to avoid a warning if the timezone is not set in php.ini
SetupUtils::ExitMaintenanceMode(false);
/////////////////////////////////////////////////////////////////////
// Fake functions to protect the first run of the installer
// in case the PHP JSON module is not installed...
if (!function_exists('json_encode'))
{
function json_encode($value, $options = null)
{
return '[]';
}
}
if (!function_exists('json_decode'))
{
function json_decode($json, $assoc=null)
{
return array();
}
}
/////////////////////////////////////////////////////////////////////
$oWizard = new WizardController('WizStepWelcome');
$oWizard->Run();