From 70efa371099f432c7bb678e40475f7ed8afd243c Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 4 Dec 2020 18:28:39 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03253=20Fix=20setup=20crashing=20on=20inc?= =?UTF-8?q?ompatible=20PHP=20versions=20(#178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now have a new setup landing page. The old one is renamed setup/wizard.php This contains revert for ":bug: Fix setup homepage error with PHP < 7.1.0" (91c6916d860e01e25bd5a28469b56952955e3a8e) => it was one of the modifications that caused the setup to crash before this ! --- core/ormlinkset.class.inc.php | 4 +- setup/index.php | 88 ++++++++++++++++++++++------------- setup/wizard.php | 64 +++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 35 deletions(-) create mode 100644 setup/wizard.php diff --git a/core/ormlinkset.class.inc.php b/core/ormlinkset.class.inc.php index 7a307c129..822bd3045 100644 --- a/core/ormlinkset.class.inc.php +++ b/core/ormlinkset.class.inc.php @@ -30,8 +30,8 @@ require_once('dbobjectiterator.php'); class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator { - const LINK_ALIAS = 'Link'; - const REMOTE_ALIAS = 'Remote'; + public const LINK_ALIAS = 'Link'; + public const REMOTE_ALIAS = 'Remote'; protected $sHostClass; // subclass of DBObject protected $sAttCode; // xxxxxx_list diff --git a/setup/index.php b/setup/index.php index c98ea1d8d..e61956cff 100644 --- a/setup/index.php +++ b/setup/index.php @@ -1,6 +1,13 @@ + + + +iTop Setup - redirection + + + + +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 << +//bSkipErrorDisplay = true; +//document.location = "wizard.php"; +// +//HTML; +?> + + diff --git a/setup/wizard.php b/setup/wizard.php new file mode 100644 index 000000000..6c735b09c --- /dev/null +++ b/setup/wizard.php @@ -0,0 +1,64 @@ +Run();