forked from extern/egroupware
fixing unhandled "MySQL server has gone away" in PHP 8.1
This commit is contained in:
parent
53c2719497
commit
b05d67847b
@ -754,8 +754,6 @@ class Db
|
||||
*/
|
||||
function query($Query_String, $line = '', $file = '', $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=self::FETCH_BOTH, $reconnect=true)
|
||||
{
|
||||
unset($line, $file); // not used anymore
|
||||
|
||||
if ($Query_String == '')
|
||||
{
|
||||
return 0;
|
||||
@ -793,14 +791,20 @@ class Db
|
||||
{
|
||||
$rs = $this->Link_ID->Execute($Query_String, $inputarr);
|
||||
}
|
||||
$this->Errno = 2006;
|
||||
$this->Error = $this->Link_ID->ErrorMsg();
|
||||
}
|
||||
// PHP 8.1 mysqli throws its own exception
|
||||
catch(\mysqli_sql_exception $e) {
|
||||
throw new Db\Exception($e->getMessage(), $e->getCode(), $e);
|
||||
if (!($reconnect && $this->Type == 'mysql' && ($e->getCode() == 2006 || $e->getMessage() === 'MySQL server has gone away')))
|
||||
{
|
||||
throw new Db\Exception($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
_egw_log_exception($e);
|
||||
$this->Errno = $e->getCode();
|
||||
$this->Error = $e->getMessage();
|
||||
}
|
||||
$this->Row = 0;
|
||||
$this->Errno = $this->Link_ID->ErrorNo();
|
||||
$this->Error = $this->Link_ID->ErrorMsg();
|
||||
|
||||
if ($this->query_log && ($f = @fopen($this->query_log,'a+')))
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ function _egw_log_exception($e,&$headline=null)
|
||||
if(isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] !== 'cli')
|
||||
{
|
||||
error_log($headline.($e instanceof egw_exception_warning ? ': ' : ' ('.get_class($e).'): ').
|
||||
$e->getMessage().(!empty($e->details) ? ': '.$e->details : ''));
|
||||
$e->getMessage().' ('.$e->getCode().')'.(!empty($e->details) ? ': '.$e->details : ''));
|
||||
error_log('File: '.str_replace(EGW_SERVER_ROOT, '', $e->getFile()).', Line: '.$e->getLine());
|
||||
foreach($trace as $line)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user