Commit 409ad9a7 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Feature Fixes #11931: Report minimal required PHP version and stop, if PHP version is too low.

parent 80f2c05e
Pipeline #4929 failed with stages
in 2 minutes and 53 seconds
......@@ -491,6 +491,9 @@ Extension Manager: QFQ Configuration
| showDebugInfo | auto | FE - Possible values: yes|no|auto|download. For 'auto': If a BE User is |
| | | logged in, a debug information will be shown on the FE. |
+-----------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| reportMinPhpVersion | auto | Possible values: yes|no|auto. For 'auto': If a BE User is logged in, it |
| | | becomes 'yes'. If installed PHP version is too low, report and stop QFQ. |
+-----------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| Database |
+-----------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| init | init=SET names utf8; SET sql_mode = | Global init for using the database. For 'sql_mode="NO_ENGINE_SUBSTITUTION"'|
......
......@@ -148,7 +148,7 @@ const ERROR_UNKNOW_SANITIZE_CLASS = 1001;
const ERROR_QUIT_QFQ_REGULAR = 1001;
const ERROR_WIPE_NOT_IMPLEMENTED_FOR_STORE = 1002;
const ERROR_CODE_SHOULD_NOT_HAPPEN = 1003;
const ERROR_SIP_MALFORMED = 1005;
const ERROR_PHP_VERSION = 1005;
const ERROR_SIP_INVALID = 1006;
const ERROR_MISSING_RECORD_ID = 1007;
const ERROR_IN_SQL_STATEMENT = 1008;
......@@ -523,12 +523,14 @@ const SYSTEM_REPORT_AS_FILE_AUTO_EXPORT = 'reportAsFileAutoExport';
const SYSTEM_SHOW_DEBUG_INFO = 'showDebugInfo';
const SYSTEM_SHOW_DEBUG_INFO_YES = 'yes';
const SYSTEM_SHOW_DEBUG_INFO_NO = 'no';
const SYSTEM_SHOW_DEBUG_INFO_AUTO = 'auto'; // Remains on value 'auto' as long as there is no BE User logged in. In other words: 'auto'='no'. #5031
const SYSTEM_SHOW_DEBUG_INFO_DOWNLOAD = 'download';
//const SYSTEM_CSS_LINK_CLASS_INTERNAL = 'CSS_LINK_CLASS_INTERNAL';
//const SYSTEM_CSS_LINK_CLASS_EXTERNAL = 'CSS_LINK_CLASS_EXTERNAL';
const SYSTEM_REPORT_MIN_PHP_VERSION = 'reportMinPhpVersion';
const SYSTEM_REPORT_MIN_PHP_VERSION_YES = 'yes';
const SYSTEM_REPORT_MIN_PHP_VERSION_AUTO = 'auto'; // Remains on value 'auto' as long as there is no BE User logged in. In other words: 'auto'='no'.
const MIN_PHP_VERSION = "7.2.0"; // Currently the PHP Spreadsheet library needs at least 7.2
const SYSTEM_CSS_CLASS_QFQ_CONTAINER = 'cssClassQfqContainer';
const SYSTEM_CSS_CLASS_QFQ_FORM = 'cssClassQfqForm';
const SYSTEM_CSS_CLASS_QFQ_FORM_PILL = 'cssClassQfqFormPill';
......
......@@ -206,6 +206,12 @@ class QuickFormQuery {
// Save pathFileName for use in inline editor
$this->t3data[T3DATA_REPORT_PATH_FILENAME] = $reportPathFileNameFull;
if (SYSTEM_REPORT_MIN_PHP_VERSION_YES == $this->store::getVar(SYSTEM_REPORT_MIN_PHP_VERSION, STORE_SYSTEM)) {
if (version_compare(PHP_VERSION, MIN_PHP_VERSION) < 0) {
throw new \UserReportException("Minimal required PHP Version: " . MIN_PHP_VERSION, ERROR_PHP_VERSION);
}
}
}
/**
......
......@@ -12,9 +12,9 @@ use IMATHUZH\Qfq\Core\Exception\Thrower;
use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\OnString;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Helper\OnString;
/**
* Class Config
......@@ -28,7 +28,7 @@ class Config {
SYSTEM_DB_1_USER => null,
SYSTEM_DB_1_PASSWORD => null,
SYSTEM_DB_1_SERVER => "localhost",
SYSTEM_DB_1_NAME=> null,
SYSTEM_DB_1_NAME => null,
];
/**
......@@ -40,8 +40,7 @@ class Config {
* @throws \UserFormException
* @throws \UserReportException
*/
public static function get(string $key)
{
public static function get(string $key) {
self::readConfig(); // only reads once
return self::$config[$key] ?? null;
}
......@@ -55,8 +54,7 @@ class Config {
* @throws \UserFormException
* @throws \UserReportException
*/
public static function getConfigArray($PhpUnitOverloadCwdToConfigFile = ''): array
{
public static function getConfigArray($PhpUnitOverloadCwdToConfigFile = ''): array {
self::readConfig($PhpUnitOverloadCwdToConfigFile); // only reads once, except if argument !=''
return self::$config;
}
......@@ -89,7 +87,7 @@ class Config {
// check required keys
foreach (self::CONFIG_REQUIRED_TEMPLATE as $key => $value) {
if (!array_key_exists($key, $config) || is_null($config[$key]) || $config[$key] === '') {
Thrower::userFormException("Required key '$key' missing in config file " . CONFIG_QFQ_JSON, "Config file: $cwdToConfigFile");
Thrower::userFormException("Required key '$key' missing in config file " . CONFIG_QFQ_JSON, "Config file: $cwdToConfigFile");
}
}
......@@ -155,8 +153,7 @@ class Config {
* @throws \UserFormException
* @throws \CodeException
*/
private static function writeConfig(array $config)
{
private static function writeConfig(array $config) {
$cwdToConf = Path::cwdToConf();
HelperFile::createPathRecursive($cwdToConf);
HelperFile::file_put_contents(Path::join($cwdToConf, CONFIG_QFQ_JSON), json_encode($config, JSON_PRETTY_PRINT));
......@@ -168,8 +165,7 @@ class Config {
* @throws \CodeException
* @throws \UserFormException
*/
public static function migrateConfigPhpToJson(): void
{
public static function migrateConfigPhpToJson(): void {
// read old config.qfq.php
$cwdToOldConfigFile = Path::cwdToApp(Path::APP_TO_TYPO3_CONF, CONFIG_QFQ_PHP);
if (!is_writeable($cwdToOldConfigFile)) {
......@@ -185,7 +181,7 @@ class Config {
SYSTEM_DB_SERVER => SYSTEM_DB_1_SERVER,
SYSTEM_DB_PASSWORD => SYSTEM_DB_1_PASSWORD,
SYSTEM_DB_NAME => SYSTEM_DB_1_NAME
], $config);
], $config);
// write new qfq.config.json
self::writeConfig($config);
......@@ -202,8 +198,7 @@ class Config {
* @throws \UserFormException
* @throws \UserReportException
*/
private static function readTypo3QfqConfig(): array
{
private static function readTypo3QfqConfig(): array {
$configT3qfq = array();
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][EXT_KEY])) {
// Typo3 version >=9
......@@ -392,6 +387,7 @@ class Config {
SYSTEM_RENDER => SYSTEM_RENDER_SINGLE,
SYSTEM_DATE_FORMAT => 'yyyy-mm-dd',
SYSTEM_SHOW_DEBUG_INFO => SYSTEM_SHOW_DEBUG_INFO_AUTO,
SYSTEM_REPORT_MIN_PHP_VERSION => SYSTEM_REPORT_MIN_PHP_VERSION_AUTO,
SYSTEM_MAIL_LOG_PATHFILENAME => '',
SYSTEM_QFQ_LOG_PATHFILENAME => '',
SYSTEM_SQL_LOG_PATHFILENAME => '',
......@@ -535,12 +531,14 @@ class Config {
* Depending on some configuration value, update corresponding values.
*
* @param array $config
*
* @return array
*/
private static function adjustConfig(array $config) {
$config[SYSTEM_SHOW_DEBUG_INFO] = self::adjustConfigDebugInfoAuto($config[SYSTEM_SHOW_DEBUG_INFO], T3Info::beUserLoggedIn());
if ($config[SYSTEM_REPORT_MIN_PHP_VERSION] == SYSTEM_REPORT_MIN_PHP_VERSION_AUTO && T3Info::beUserLoggedIn()) {
$config[SYSTEM_REPORT_MIN_PHP_VERSION] = SYSTEM_REPORT_MIN_PHP_VERSION_YES;
}
// In case the database credentials are given in the old style: copy them to the new style
if (!isset($config[SYSTEM_DB_1_USER]) && isset($config[SYSTEM_DB_USER])) {
......
......@@ -101,6 +101,9 @@ mailLog =
# cat=debug/info; type=string; label=Show debug info:Default is 'auto'. Possible values: [yes|no|auto][,download]. For 'auto': If a BE User is logged in, a debug information will be shown on the FE.
showDebugInfo = auto
# cat=debug/reportMinPhpVersion; type=string; label=Report too low PHP Version:Default is 'auto'. Possible values: [yes|no|auto]. For 'auto': If a BE User is logged in, qfq shows message and terminate.
reportMinPhpVersion = auto
# cat=database/db1; type=string; label=Init database:Default is 'set names utf8'. Optional. Might set specific settings.
init = SET names utf8; SET sql_mode = "NO_ENGINE_SUBSTITUTION";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment