diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ac53e4decaa..1bfd7b4361e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -12,12 +12,12 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2020 Demarest Maxime - * Copyright (C) 2020-2024 Charlene Benke + * Copyright (C) 2020-2024 Charlene Benke * Copyright (C) 2021-2024 Frédéric France * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2023 Joachim Küter * Copyright (C) 2023 Eric Seigne - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -255,7 +255,7 @@ function testSqlAndScriptInject($val, $type) /** * Return true if security check on parameters are OK, false otherwise. * - * @param string|array $var Variable name + * @param string|array $var Variable name * @param int<0,2> $type 1=GET, 0=POST, 2=PHP_SELF * @param int<0,1> $stopcode 0=No stop code, 1=Stop code (default) if injection found * @return boolean True if there is no injection. @@ -3133,7 +3133,7 @@ function printDropdownQuickadd($mode = 0) // Allow the $items of the menu to be manipulated by modules $parameters = array(); $hook_items = $items; - $reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks @phan-suppress-current-line PhanTypeMismatchArgument if (is_numeric($reshook) && !empty($hookmanager->resArray) && is_array($hookmanager->resArray)) { if ($reshook == 0) { $items['items'] = array_merge($items['items'], $hookmanager->resArray); // add @@ -3498,7 +3498,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ //$textsearch = $langs->trans("Search"); $textsearch = ''.$langs->trans("Search"); - $searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, 'accesskey="s"', 1, 0, (getDolGlobalString('MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY') ? 0 : 1), 'vmenusearchselectcombo', 1, $textsearch, 1, $stringforfirstkey.' s'); + $searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, (string) $selected, 'accesskey="s"', 1, 0, (getDolGlobalString('MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY') ? 0 : 1), 'vmenusearchselectcombo', 1, $textsearch, 1, $stringforfirstkey.' s'); } else { if (is_array($arrayresult)) { // @phan-suppress-next-line PhanEmptyForeach // array is really empty in else case. diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index e2ccbe25dd2..41cb8f391cd 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -10,7 +10,7 @@ * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2011 Philippe Grand * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +45,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; * @var string $dolibarr_main_url_root_alt */ +' +@phan-var-force ?string $dolibarr_main_db_prefix +@phan-var-force ?string $dolibarr_main_db_encryption +@phan-var-force ?string $dolibarr_main_db_cryptkey +@phan-var-force ?string $dolibarr_main_limit_users +@phan-var-force ?string $dolibarr_main_url_root_alt +'; + if (!function_exists('is_countable')) { /** * function is_countable (to remove when php version supported will be >= 7.3) @@ -99,7 +107,7 @@ if (!empty($dolibarr_main_document_root_alt)) { foreach ($values as $value) { $conf->file->dol_document_root['alt'.($i++)] = (string) $value; } - $values = preg_split('/[;,]/', $dolibarr_main_url_root_alt); + $values = preg_split('/[;,]/', (string) $dolibarr_main_url_root_alt); $i = 0; foreach ($values as $value) { if (preg_match('/^http(s)?:/', $value)) { @@ -178,14 +186,16 @@ unset($conf->db->pass); // This is to avoid password to be shown in memory/swap /* * Object $user */ -if (!defined('NOREQUIREUSER')) { +if (!defined('NOREQUIREUSER') && $db !== null) { $user = new User($db); } /* * Create the global $hookmanager object */ -$hookmanager = new HookManager($db); +if ($db !== null) { + $hookmanager = new HookManager($db); +} /* @@ -212,10 +222,12 @@ if (!is_numeric($conf->entity)) { } // Here we read database (llx_const table) and define conf var $conf->global->XXX. //print "We work with data into entity instance number '".$conf->entity."'"; -$conf->setValues($db); +if ($db !== null) { + $conf->setValues($db); +} // Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. -if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) { +if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC') && $db != null) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $mysoc = new Societe($db);