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