N°3952 - code hardening (merged from support/2.6)

This commit is contained in:
Eric
2021-05-27 09:55:16 +02:00
5 changed files with 54 additions and 21 deletions

View File

@@ -25,6 +25,7 @@ require_once(APPROOT.'/setup/setuppage.class.inc.php');
require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
require_once(APPROOT.'/setup/wizardsteps.class.inc.php');
session_start();
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')));
@@ -33,21 +34,17 @@ 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'))
{
if (!function_exists('json_encode')) {
function json_encode($value, $options = null)
{
return '[]';
}
}
if (!function_exists('json_decode'))
{
function json_decode($json, $assoc=null)
if (!function_exists('json_decode')) {
function json_decode($json, $assoc = null)
{
return array();
}
@@ -57,4 +54,13 @@ if (!function_exists('json_decode'))
//N°3671 setup context: force $bForceTrustProxy to be persisted in next calls
utils::GetAbsoluteUrlAppRoot(true);
$oWizard = new WizardController('WizStepWelcome');
$oWizard->Run();
//N°3952
if (SetupUtils::IsSessionSetupTokenValid()) {
// Normal operation
$oWizard->Run();
} else {
SetupUtils::ExitMaintenanceMode(false);
// Force initializing the setup
$oWizard->Start();
SetupUtils::CreateSetupToken();
}