diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index 60b129b5a08..046f8504722 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -5,7 +5,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014-2015 Raphaël Doursenaud - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -372,7 +372,7 @@ interface Database * * @param string $table Name of table * @param string $field_name Name of field to add - * @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value] + * @param array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int,noteditable?:int,default?:string,extra?:string,null?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value] * @param string $field_position Optional ex .: "after field stuff" * @return int Return integer <0 if KO, >0 if OK */ diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index f572225a3ab..160805761bc 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Charlene Benke * Copyright (C) 2024 Frédéric France * @@ -962,7 +962,7 @@ class DoliDBMysqli extends DoliDB * * @param string $table Name of table * @param string $field_name Name of field to add - * @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative table with description of field to insert [parameter name][parameter value] + * @param array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int,noteditable?:int,default?:string,extra?:string,null?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value] * @param string $field_position Optional e.g.: "after some_field" * @return int Return integer <0 if KO, >0 if OK */ diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 28561f73648..02288a05e21 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2012 Yann Droneaud * Copyright (C) 2012 Florian Henry * Copyright (C) 2015 Marcos García - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -1194,7 +1194,7 @@ class DoliDBPgsql extends DoliDB * * @param string $table Name of table * @param string $field_name Name of field to add - * @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value] + * @param array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int,noteditable?:int,default?:string,extra?:string,null?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value] * @param string $field_position Optionnel ex.: "after champtruc" * @return int Return integer <0 if KO, >0 if OK */ diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 23fa3483e76..e10cda471b0 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -939,7 +939,7 @@ class DoliDBSqlite3 extends DoliDB * * @param string $table Name of table * @return array> Table with information of columns in the table - + * * TODO modify for sqlite */ public function DDLInfoTable($table) @@ -1104,7 +1104,7 @@ class DoliDBSqlite3 extends DoliDB * * @param string $table Table name * @param string $field_name Field name to add - * @param array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative table with description of field to insert [parameter name][parameter value] + * @param array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int,noteditable?:int,default?:string,extra?:string,null?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value] * @param string $field_position Optional e.g.: "after some_field" * @return int Return integer <0 if KO, >0 if OK */ diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index 9211e8e5fae..a7b45a7da6b 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -535,7 +535,7 @@ class TraceableDB extends DoliDB * * @param string $table Name of table * @param string $field_name Name of field to add - * @param array{type:string,label:string,enabled:int|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Tableau associatif de description du champ a inserer[nom du parameter][valeur du parameter] + * @param array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int,noteditable?:int,default?:string,extra?:string,null?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array,comment?:string} $field_desc Associative array of description of the field to insert [parameter name][parameter value] * @param string $field_position Optionnel ex.: "after champtruc" * @return int Return integer <0 if KO, >0 if OK */ diff --git a/htdocs/index.php b/htdocs/index.php index 5e2b667dbae..a7b2c9acf5e 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2021-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -677,7 +677,7 @@ if (!getDolGlobalString('MAIN_DISABLE_GLOBAL_WORKBOARD') && getDolGlobalInt('MAI } else { $weatherDashBoard .= ' '.$langs->transnoentitiesnoconv( "NActionsLate", - $totalLateNumber + (string) $totalLateNumber ).''."\n"; if ($totallatePercentage > 0) { $weatherDashBoard .= ' '.$langs->trans( diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 2e9e89c8dc9..e60249532db 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -6,7 +6,7 @@ * Copyright (C) 2013-2014 Juanjo Menent * Copyright (C) 2014 Marcos García * Copyright (C) 2015-2016 Raphaël Doursenaud - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024-2025 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -374,7 +374,7 @@ if (!file_exists($conffile)) { $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, (string) $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port); if ($db->connected && $db->database_selected) { $ok = true; } @@ -382,6 +382,7 @@ if (!file_exists($conffile)) { } } + $dolibarrlastupgradeversionarray = array(); // If database access is available, we set more variables if ($ok) { if (empty($dolibarr_main_db_encryption)) { @@ -514,7 +515,7 @@ if (!file_exists($conffile)) { } if ($ok) { - if (count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known + if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) { // If database access is available and last upgrade version is known // Now we check if this is the first qualified choice if ($allowupgrade && empty($foundrecommandedchoice) && (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2) diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 5c73f49a6b1..1514f9e7e40 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -6,7 +6,7 @@ * Copyright (C) 2004 Sebastien DiCintio * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2016 Raphaël Doursenaud - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024-2025 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -42,6 +42,37 @@ include_once 'inc.php'; * @var string $conffile * @var string $conffiletoshow */ +' +@phan-var-force string $dolibarr_main_db_host +@phan-var-force string $dolibarr_main_db_port +@phan-var-force string $dolibarr_main_db_name +@phan-var-force string $dolibarr_main_db_user +@phan-var-force string $dolibarr_main_db_pass +@phan-var-force string $dolibarr_main_db_encrypted_pass +@phan-var-force string $conffile +@phan-var-force string $conffiletoshow +@phan-var-force ?bool $force_install_ +@phan-var-force ?string $force_install_packager +@phan-var-force ?string $force_install_message +@phan-var-force ?string $force_install_main_data_root +@phan-var-force ?int<0,2> $force_install_noedit +@phan-var-force ?string $force_install_type +@phan-var-force ?string $force_install_dbserver +@phan-var-force ?string $force_install_port +@phan-var-force ?string $force_install_database +@phan-var-force ?string $force_install_prefix +@phan-var-force ?string $force_install_createdatabase +@phan-var-force ?string $force_install_databaselogin +@phan-var-force ?string $force_install_databasepass +@phan-var-force ?string $force_install_databaserootlogin +@phan-var-force ?string $force_install_databaserootpass +@phan-var-force ?string $force_install_dolibarrlogin +@phan-var-force ?string $force_install_nophpinfo +@phan-var-force ?string $force_install_lockinstall +@phan-var-force ?string $force_install_distrib +@phan-var-force ?string $db_user_root +@phan-var-force ?string $db_pass_root +'; $err = 0; @@ -339,6 +370,8 @@ if (!empty($force_install_noedit)) { $defaultype = 'mysql'; } + $testclass = ''; + $testfunction = null; // Show line into list if ($type == 'mysql') { $testfunction = 'mysql_connect'; diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 3fd55c11bc4..b1c967e790e 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -7,7 +7,7 @@ * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2021 Charlene Benke * Copyright (C) 2023 Alexandre Janniaux - * 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 @@ -48,6 +48,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +' +@phan-var-force ?string $dolibarr_main_url_root_alt +@phan-var-force ?string $dolibarr_main_db_prefix +'; + $conf = new Conf(); // Force $_REQUEST["logtohtml"] diff --git a/htdocs/install/index.php b/htdocs/install/index.php index d62f82eaa27..c089a90fdf4 100644 --- a/htdocs/install/index.php +++ b/htdocs/install/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2005 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2016 Raphaël Doursenaud + * Copyright (C) 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 @@ -63,7 +64,7 @@ print ''; print ''; print ''; print ''; diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 4df5b65250d..ccf25a7f725 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -5,7 +5,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2021-2024 Frédéric France * Copyright (C) 2023 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Vincent de Grandpré * * This program is free software; you can redistribute it and/or modify @@ -43,6 +43,11 @@ if (file_exists($conffile)) { * @var string $dolibarr_main_db_pass */ +' +@phan-var-force ?string $dolibarr_main_db_encryption +@phan-var-force ?string $dolibarr_main_db_cryptkey +'; + require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; include_once $dolibarr_main_document_root.'/core/lib/images.lib.php'; require_once $dolibarr_main_document_root.'/core/class/extrafields.class.php'; @@ -858,6 +863,7 @@ if ($ok && GETPOST('clean_orphelin_dir', 'alpha')) { $filearray = dol_dir_list($upload_dir, "files", 1, '', array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'), '', SORT_DESC, 1, 1); + $object_instance = null; // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company') { include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -954,6 +960,7 @@ if ($ok && GETPOST('clean_orphelin_dir', 'alpha')) { } } +$methodtofix = ''; // clean_linked_elements: Check and clean linked elements if ($ok && GETPOST('clean_product_stock_batch', 'alpha')) { $methodtofix = GETPOST('methodtofix', 'alpha') ? GETPOST('methodtofix', 'alpha') : 'updatestock'; diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 6ec6c03743d..9d1bbe6d463 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2015-2016 Raphaël Doursenaud - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -101,8 +101,9 @@ if (@file_exists($forcedfile)) { $main_data_dir = $argv[4]; // override when executing the script in command line } // In mode 3 the main_url is custom - if ($force_install_noedit != 3) - $main_url = detect_dolibarr_main_url_root(); + if ($force_install_noedit != 3) { + $main_url = detect_dolibarr_main_url_root(); + } if (!empty($argv[5])) { $main_url = $argv[5]; // override when executing the script in command line } @@ -567,14 +568,20 @@ if (!$error && $db->connected && $action == "set") { // Test on permission not r // Check database connection - $db = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, (int) $conf->db->port); - - if ($db->error) { - print '
'.$db->error.'
'; + $db = null; + if ($databasefortest === null) { + print '
Database name can not be empty
'; $error++; + } else { + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $userroot, $passroot, $databasefortest, (int) $conf->db->port); + + if ($db->error) { + print '
'.$db->error.'
'; + $error++; + } } - if (!$error) { + if (!$error && $db !== null) { if ($db->connected) { $resultbis = 1; diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index a0b64c28a22..c58c9fe6fc4 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2015 Cedric GROSS * Copyright (C) 2015-2016 Raphaël Doursenaud - * 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 @@ -141,6 +141,7 @@ if ($action == "set") { // Test on permission not required. Already managed by } + $versionarray = array(); // Display version / Affiche version if ($ok) { $version = $db->getVersion(); @@ -166,7 +167,7 @@ if ($action == "set") { // Test on permission not required. Already managed by // To say that SQL we pass to query are already escaped for mysql, so we need to unescape them if (property_exists($db, 'unescapeslashquot')) { - $db->unescapeslashquot = true; + $db->unescapeslashquot = true; // @phan-suppress-current-line PhanUndeclaredProperty } /************************************************************************************** @@ -396,6 +397,7 @@ if ($action == "set") { // Test on permission not required. Already managed by ***************************************************************************************/ if ($ok && $createfunctions) { // For this file, we use a directory according to database type + $dir = null; if ($choix == 1) { $dir = "mysql/functions/"; } elseif ($choix == 2) { @@ -408,11 +410,11 @@ if ($action == "set") { // Test on permission not required. Already managed by // Creation of data $file = "functions.sql"; - if (file_exists($dir.$file)) { + if ($dir !== null && file_exists($dir.$file)) { $fp = fopen($dir.$file, "r"); dolibarr_install_syslog("step2: open function file ".$dir.$file." handle=".(is_bool($fp) ? json_encode($fp) : $fp)); + $buffer = ''; if ($fp) { - $buffer = ''; while (!feof($fp)) { $buf = fgets($fp, 4096); if (substr($buf, 0, 2) != '--') { diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 7b410b14656..9d13cd986ad 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -5,6 +5,7 @@ * Copyright (C) 2004 Sebastien DiCintio * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-2016 Raphaël Doursenaud + * Copyright (C) 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 +46,12 @@ require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; // for dol_hash require_once $dolibarr_main_document_root.'/core/lib/functions2.lib.php'; +' +@phan-var-force ?string $modulesdir +@phan-var-force ?string $dolibarr_main_db_encryption +@phan-var-force ?string $dolibarr_main_db_cryptkey +'; + global $langs; $versionfrom = GETPOST("versionfrom", 'alpha', 3) ? GETPOST("versionfrom", 'alpha', 3) : (empty($argv[1]) ? '' : $argv[1]); diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 4a09cff906f..8de7713dd32 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2015-2016 Raphaël Doursenaud - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -180,6 +180,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ } // Affiche version + $versionarray = array(); if ($ok) { $version = $db->getVersion(); $versionarray = $db->getVersionArray(); @@ -210,8 +211,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Test database version is not forbidden for migration if (empty($ignoredbversion)) { $dbversion_disallowed = array( - array('type'=>'mysql', 'version'=>array(5, 5, 40)), - array('type'=>'mysqli', 'version'=>array(5, 5, 40)) //, + array('type' => 'mysql', 'version' => array(5, 5, 40)), + array('type' => 'mysqli', 'version' => array(5, 5, 40)) //, //array('type'=>'mysql','version'=>array(5,5,41)), //array('type'=>'mysqli','version'=>array(5,5,41)) );
'.$langs->trans("DefaultLanguage").' : '; -print $formadmin->select_language('auto', 'selectlang', 1, 0, 0, 1); +print $formadmin->select_language('auto', 'selectlang', 1, array(), 0, 1); print '