mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Only check for existing method expresion() when it actually will be called.
Datasources that use calculate() should not be forced to implement expression() as well
This commit is contained in:
parent
8c631fa022
commit
30268f6a08
1 changed files with 2 additions and 2 deletions
|
@ -2749,12 +2749,12 @@ class Model extends Object implements CakeEventListener {
|
||||||
if ($state === 'before') {
|
if ($state === 'before') {
|
||||||
$db = $this->getDataSource();
|
$db = $this->getDataSource();
|
||||||
$query['order'] = false;
|
$query['order'] = false;
|
||||||
if (!method_exists($db, 'calculate') || !method_exists($db, 'expression')) {
|
if (!method_exists($db, 'calculate')) {
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
if (empty($query['fields'])) {
|
if (empty($query['fields'])) {
|
||||||
$query['fields'] = $db->calculate($this, 'count');
|
$query['fields'] = $db->calculate($this, 'count');
|
||||||
} elseif (is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) {
|
} elseif (method_exists($db, 'expression') && is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) {
|
||||||
$query['fields'] = $db->calculate($this, 'count', array(
|
$query['fields'] = $db->calculate($this, 'count', array(
|
||||||
$db->expression($query['fields']), 'count'
|
$db->expression($query['fields']), 'count'
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue