diff --git a/api/src/Db.php b/api/src/Db.php index 74d496291c..cc27d991e5 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -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+'))) { diff --git a/api/src/loader/exception.php b/api/src/loader/exception.php index 43750b6afd..a678037ea2 100755 --- a/api/src/loader/exception.php +++ b/api/src/loader/exception.php @@ -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) {