mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 20:49:04 +01:00
fix PHP 8.1 throws \mysqli_sql_exception or \PDOException for SQL errors
- change them to our regular Api\Db\Exception - for prop(find|patch) explicitly catch PDOException to deal more graceful with non-ascii prop-names
This commit is contained in:
parent
c4e0989bf9
commit
9a0cc36366
@ -798,6 +798,8 @@ class Db
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
if ($num_rows > 0)
|
if ($num_rows > 0)
|
||||||
{
|
{
|
||||||
$rs = $this->Link_ID->SelectLimit($Query_String, $num_rows, (int)$offset, $inputarr);
|
$rs = $this->Link_ID->SelectLimit($Query_String, $num_rows, (int)$offset, $inputarr);
|
||||||
@ -806,6 +808,11 @@ class Db
|
|||||||
{
|
{
|
||||||
$rs = $this->Link_ID->Execute($Query_String, $inputarr);
|
$rs = $this->Link_ID->Execute($Query_String, $inputarr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// PHP 8.1 mysqli throws its own exception
|
||||||
|
catch(\mysqli_sql_exception $e) {
|
||||||
|
throw new Db\Exception($e->getMessage(), $e->getCode(), $e);
|
||||||
|
}
|
||||||
$this->Row = 0;
|
$this->Row = 0;
|
||||||
$this->Errno = $this->Link_ID->ErrorNo();
|
$this->Errno = $this->Link_ID->ErrorNo();
|
||||||
$this->Error = $this->Link_ID->ErrorMsg();
|
$this->Error = $this->Link_ID->ErrorMsg();
|
||||||
|
@ -27,10 +27,10 @@ class Exception extends \egw_exception_db
|
|||||||
* @param string $msg =null message, default "Database error!"
|
* @param string $msg =null message, default "Database error!"
|
||||||
* @param int $code =100
|
* @param int $code =100
|
||||||
*/
|
*/
|
||||||
function __construct($msg=null,$code=100)
|
function __construct($msg=null, $code=100, \Exception $previous=null)
|
||||||
{
|
{
|
||||||
if (is_null($msg)) $msg = lang('Database error!');
|
if (is_null($msg)) $msg = lang('Database error!');
|
||||||
|
|
||||||
parent::__construct($msg,$code);
|
parent::__construct($msg, $code, $previous);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1944,6 +1944,8 @@ GROUP BY A.fs_id';
|
|||||||
return false; // permission denied
|
return false; // permission denied
|
||||||
}
|
}
|
||||||
$ins_stmt = $del_stmt = null;
|
$ins_stmt = $del_stmt = null;
|
||||||
|
|
||||||
|
try {
|
||||||
foreach ($props as &$prop)
|
foreach ($props as &$prop)
|
||||||
{
|
{
|
||||||
if (!array_key_exists('name', $prop))
|
if (!array_key_exists('name', $prop))
|
||||||
@ -1982,6 +1984,12 @@ GROUP BY A.fs_id';
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// catch exception for inserting or deleting non-ascii prop_names
|
||||||
|
catch (\PDOException $e) {
|
||||||
|
_egw_log_exception($e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2014,10 +2022,16 @@ GROUP BY A.fs_id';
|
|||||||
(!is_null($ns) ? ' AND prop_namespace=?' : '');
|
(!is_null($ns) ? ' AND prop_namespace=?' : '');
|
||||||
if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
|
if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
|
||||||
|
|
||||||
|
try {
|
||||||
$stmt = self::$pdo->prepare($query);
|
$stmt = self::$pdo->prepare($query);
|
||||||
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
|
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
|
||||||
$stmt->execute(!is_null($ns) ? array($ns) : array());
|
$stmt->execute(!is_null($ns) ? array($ns) : array());
|
||||||
|
}
|
||||||
|
// cat exception trying to search for non-ascii prop_name
|
||||||
|
catch (\PDOException $e) {
|
||||||
|
_egw_log_exception($e);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$props = array();
|
$props = array();
|
||||||
foreach($stmt as $row)
|
foreach($stmt as $row)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user