Debug install v16 with php 8.1

This commit is contained in:
Laurent Destailleur 2022-07-04 03:06:56 +02:00
parent e4e0bdbe96
commit de71df9df2
4 changed files with 26 additions and 11 deletions

View File

@ -92,14 +92,14 @@ class DoliDBMysqli extends DoliDB
// We do not try to connect to database, only to server. Connect to database is done later in constrcutor
$this->db = $this->connect($host, $user, $pass, '', $port);
if ($this->db->connect_errno) {
$this->connected = false;
$this->ok = false;
$this->error = $this->db->connect_error;
dol_syslog(get_class($this)."::DoliDBMysqli Connect error: ".$this->error, LOG_ERR);
} else {
if ($this->db && empty($this->db->connect_errno)) {
$this->connected = true;
$this->ok = true;
} else {
$this->connected = false;
$this->ok = false;
$this->error = empty($this->db) ? 'Failed to connect' : $this->db->connect_error;
dol_syslog(get_class($this)."::DoliDBMysqli Connect error: ".$this->error, LOG_ERR);
}
// If server connection is ok, we try to connect to the database
@ -204,7 +204,12 @@ class DoliDBMysqli extends DoliDB
{
// phpcs:enable
dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG);
return $this->db->select_db($database);
$result = false;
try {
$result = $this->db->select_db($database);
} catch (Exception $e) {
}
return $result;
}
@ -216,7 +221,7 @@ class DoliDBMysqli extends DoliDB
* @param string $passwd Password
* @param string $name Name of database (not used for mysql, used for pgsql)
* @param integer $port Port of database server
* @return mysqli Database access object
* @return mysqli|null Database access object
* @see close()
*/
public function connect($host, $login, $passwd, $name, $port = 0)
@ -228,7 +233,13 @@ class DoliDBMysqli extends DoliDB
// Can also be
// mysqli::init(); mysql::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0'); mysqli::options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
// return mysqli::real_connect($host, $user, $pass, $db, $port);
return new mysqli($host, $login, $passwd, $name, $port);
$tmp = false;
try {
$tmp = new mysqli($host, $login, $passwd, $name, $port);
} catch (Exception $e) {
dol_syslog(get_class($this)."::connect failed", LOG_DEBUG);
}
return $tmp;
}
/**

View File

@ -419,7 +419,11 @@ class DoliDBPgsql extends DoliDB
// try first Unix domain socket (local)
if ((!empty($host) && $host == "socket") && !defined('NOLOCALSOCKETPGCONNECT')) {
$con_string = "dbname='".$name."' user='".$login."' password='".$passwd."'"; // $name may be empty
$this->db = @pg_connect($con_string);
try {
$this->db = @pg_connect($con_string);
} catch (Exception $e) {
// No message
}
}
// if local connection failed or not requested, use TCP/IP

View File

@ -80,7 +80,7 @@ $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf
if ($db->ok) {
print '<tr><td><label for="login">'.$langs->trans("Login").' :</label></td><td>';
print '<input id="login" name="login" type="text" value="'.(GETPOSTISSET("login") ? GETPOST("login", 'alpha') : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')).'"'.(@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '').'></td></tr>';
print '<input id="login" name="login" type="text" value="'.(GETPOSTISSET("login") ? GETPOST("login", 'alpha') : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')).'"'.(@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '').' autofocus></td></tr>';
print '<tr><td><label for="pass">'.$langs->trans("Password").' :</label></td><td>';
print '<input type="password" id="pass" name="pass" autocomplete="new-password" minlength="8"></td></tr>';
print '<tr><td><label for="pass_verif">'.$langs->trans("PasswordAgain").' :</label></td><td>';