mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-25 00:07:20 +00:00
Added PDOException wrapper to avoid creating dynamic property. (#77)
This commit is contained in:
parent
7e1da9a5ca
commit
61c8f9ad25
3 changed files with 26 additions and 3 deletions
|
@ -59,6 +59,10 @@ It means that composer will look at `master` branch of repository configured und
|
|||
|
||||
## Changelog
|
||||
|
||||
### 2024-09-21
|
||||
|
||||
- Added wrapper for PDOException to avoid creating dynamic property `queryString`.
|
||||
|
||||
### 2024-07-24
|
||||
|
||||
- Csrf vulnerabity fix back ported from Cake PHP 3
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
App::uses('DataSource', 'Model/Datasource');
|
||||
App::uses('PDOExceptionWithQueryString', 'Model/Datasource');
|
||||
App::uses('CakeText', 'Utility');
|
||||
App::uses('View', 'View');
|
||||
|
||||
|
@ -512,12 +513,13 @@ class DboSource extends DataSource {
|
|||
}
|
||||
return $query;
|
||||
} catch (PDOException $e) {
|
||||
$wrapperException = new PDOExceptionWithQueryString($e);
|
||||
if (isset($query->queryString)) {
|
||||
$e->queryString = $query->queryString;
|
||||
$wrapperException->queryString = $query->queryString;
|
||||
} else {
|
||||
$e->queryString = $sql;
|
||||
$wrapperException->queryString = $sql;
|
||||
}
|
||||
throw $e;
|
||||
throw $wrapperException;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
17
lib/Cake/Model/Datasource/PDOExceptionWithQueryString.php
Normal file
17
lib/Cake/Model/Datasource/PDOExceptionWithQueryString.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
class PDOExceptionWithQueryString extends PDOException {
|
||||
|
||||
public string $queryString = "";
|
||||
|
||||
/**
|
||||
* Wrapper for PDOException to avoid creating dynamic property.
|
||||
*
|
||||
* @param PDOException $e Source exception.
|
||||
*/
|
||||
public function __construct(PDOException $e) {
|
||||
parent::__construct($e->getMessage(), 0, $e->getPrevious());
|
||||
|
||||
$this->code = $e->code;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue