fix not working installation under PHP 8.1 due to mysqli throwing errors now by default

This commit is contained in:
ralf 2022-05-20 18:00:41 +02:00
parent 3dd247f1df
commit c57ae62d1c
7 changed files with 27 additions and 27 deletions

View File

@ -125,7 +125,7 @@ class Categories
if (!$app_name) $app_name = $GLOBALS['egw_info']['flags']['currentapp']; if (!$app_name) $app_name = $GLOBALS['egw_info']['flags']['currentapp'];
if ($accountid === self::GLOBAL_ACCOUNT || if ($accountid === self::GLOBAL_ACCOUNT ||
$accountid < 0 && $GLOBALS['egw']->accounts->exists($accountid) == 2) (int)$accountid < 0 && $GLOBALS['egw']->accounts->exists($accountid) == 2)
{ {
$this->account_id = (int) $accountid; $this->account_id = (int) $accountid;
} }

View File

@ -358,7 +358,7 @@ class Db
//error_log(__METHOD__."() this->Host(s)=$this->Host, n=$n --> host=$host"); //error_log(__METHOD__."() this->Host(s)=$this->Host, n=$n --> host=$host");
$new_connection = !$this->Link_ID || !$this->Link_ID->IsConnected(); $new_connection = !$this->Link_ID || !$this->Link_ID->IsConnected();
$this->_connect($host); $this->_connect($host);
// check if connected node is healty // check if connected node is healthy
if ($new_connection && self::$health_check) if ($new_connection && self::$health_check)
{ {
call_user_func(self::$health_check, $this); call_user_func(self::$health_check, $this);

View File

@ -31,6 +31,6 @@ class Exception extends \Exception
// nothing fancy yet // nothing fancy yet
function __construct($msg=null,$code=100,\Exception $previous=null) function __construct($msg=null,$code=100,\Exception $previous=null)
{ {
return parent::__construct($msg, $code, $previous); parent::__construct($msg, $code, $previous);
} }
} }

View File

@ -354,7 +354,7 @@ class Translation
$loaded =& self::load_app_files($app, $l, null, $updated_load_via); $loaded =& self::load_app_files($app, $l, null, $updated_load_via);
} }
//error_log(__METHOD__."('$app', '$lang') instance_specific=$instance_specific, load_app(_files)() returned ".(is_array($loaded)?'Array('.count($loaded).')':array2string($loaded))); //error_log(__METHOD__."('$app', '$lang') instance_specific=$instance_specific, load_app(_files)() returned ".(is_array($loaded)?'Array('.count($loaded).')':array2string($loaded)));
if ($loaded || $instance_specific) if ($loaded)
{ {
Cache::setCache($instance_specific ? Cache::INSTANCE : Cache::TREE, Cache::setCache($instance_specific ? Cache::INSTANCE : Cache::TREE,
__CLASS__, $app.':'.$l, $loaded); __CLASS__, $app.':'.$l, $loaded);
@ -401,12 +401,17 @@ class Translation
if (!isset(self::$db)) return; if (!isset(self::$db)) return;
} }
$loaded = array(); $loaded = array();
foreach(self::$db->select(self::LANG_TABLE,'message_id,content',array( try {
'lang' => $lang, foreach (self::$db->select(self::LANG_TABLE, 'message_id,content', array(
'app_name' => $app, 'lang' => $lang,
),__LINE__,__FILE__) as $row) 'app_name' => $app,
{ ), __LINE__, __FILE__) as $row)
$loaded[strtolower($row['message_id'])] = $row['content']; {
$loaded[strtolower($row['message_id'])] = $row['content'];
}
}
catch (Db\Exception $e) {
// ignore error
} }
//error_log(__METHOD__."($app,$lang) took ".(1000*(microtime(true)-$start))." ms to load ".count($loaded)." phrases"); //error_log(__METHOD__."($app,$lang) took ".(1000*(microtime(true)-$start))." ms to load ".count($loaded)." phrases");
return $loaded; return $loaded;
@ -1174,4 +1179,4 @@ class Translation
} }
return isset($detected) ? $detected : 'iso-8859-1'; // we choose to return iso-8859-1 as default return isset($detected) ? $detected : 'iso-8859-1'; // we choose to return iso-8859-1 as default
} }
} }

View File

@ -55,7 +55,7 @@ class setup
*/ */
var $html; var $html;
var $system_charset; var $system_charset = 'utf-8';
var $lang; var $lang;
var $ConfigDomain; var $ConfigDomain;
@ -90,8 +90,6 @@ class setup
$this->detection = new setup_detection(); $this->detection = new setup_detection();
$this->process = new setup_process(); $this->process = new setup_process();
if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) $this->system_charset = $_REQUEST['system_charset'];
/* The setup application needs these */ /* The setup application needs these */
if ($html) $this->html = new setup_html(); if ($html) $this->html = new setup_html();
if ($translation) $this->translation = new setup_translation(); if ($translation) $this->translation = new setup_translation();
@ -137,7 +135,7 @@ class setup
$this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update
// we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!!
if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version if (substr($this->db->Type,0,5) === 'mysql') // we need to check the api version
{ {
$api_version = $this->db->select($this->applications_table,'app_version',array( $api_version = $this->db->select($this->applications_table,'app_version',array(
'app_name' => 'phpgwapi', 'app_name' => 'phpgwapi',

View File

@ -300,7 +300,8 @@ class setup_detection
if (!$setup_info) $setup_info = $GLOBALS['setup_info']; if (!$setup_info) $setup_info = $GLOBALS['setup_info'];
try { // catch DB errors try { // catch DB errors
if (!$GLOBALS['egw_setup']->db->Link_ID) if (empty($GLOBALS['egw_setup']->db->Link_ID) ||
empty($GLOBALS['egw_setup']->db->Link_ID->_connectionID))
{ {
$old = error_reporting(); $old = error_reporting();
error_reporting($old & ~E_WARNING); // no warnings error_reporting($old & ~E_WARNING); // no warnings
@ -310,11 +311,13 @@ class setup_detection
$GLOBALS['egw_setup']->set_table_names(); $GLOBALS['egw_setup']->set_table_names();
} }
} }
catch(Api\Db\Exception $e) { catch(\Exception $e) {
// ignore error // ignore error
} }
if (!$GLOBALS['egw_setup']->db->Link_ID || !$GLOBALS['egw_setup']->db->Link_ID->_connectionID) if (empty($GLOBALS['egw_setup']->db->Link_ID) ||
empty($GLOBALS['egw_setup']->db->Link_ID->_connectionID) ||
$GLOBALS['egw_setup']->db->Link_ID->_connectionID->connect_errno)
{ {
$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)'; $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
return 1; return 1;
@ -574,4 +577,4 @@ class setup_detection
} }
return true; return true;
} }
} }

View File

@ -342,12 +342,6 @@ switch($GLOBALS['egw_info']['setup']['stage']['db'])
else else
{ {
$s_info = $GLOBALS['egw_setup']->detection->upgrade_exclude($setup_info); $s_info = $GLOBALS['egw_setup']->detection->upgrade_exclude($setup_info);
// Set the DB's client charset if a system-charset is set
if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset']))
{
$GLOBALS['egw_setup']->system_charset = $_REQUEST['system_charset'];
$GLOBALS['egw_setup']->db->Link_ID->SetCharSet($_REQUEST['system_charset']);
}
$setup_info = $GLOBALS['egw_setup']->process->pass($s_info,'new',$_REQUEST['debug'],True); $setup_info = $GLOBALS['egw_setup']->process->pass($s_info,'new',$_REQUEST['debug'],True);
$GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
} }
@ -539,4 +533,4 @@ else
} }
$setup_tpl->pparse('out','T_setup_main'); $setup_tpl->pparse('out','T_setup_main');
$GLOBALS['egw_setup']->html->show_footer(); $GLOBALS['egw_setup']->html->show_footer();