Skip to content

Commit 130ad7e

Browse files
author
Walther Lalk
committed
Tests that callable is not a string
1 parent 7b0db0b commit 130ad7e

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Database/Expression/QueryExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function notIn($field, $values, $type = null) {
293293
* @return \Cake\Database\Expression\QueryExpression
294294
*/
295295
public function and_($conditions, $types = []) {
296-
if (is_callable($conditions)) {
296+
if (!is_string($conditions) && is_callable($conditions)) {
297297
return $conditions(new self([], $this->typeMap()->types($types)));
298298
}
299299
return new self($conditions, $this->typeMap()->types($types));
@@ -309,7 +309,7 @@ public function and_($conditions, $types = []) {
309309
* @return \Cake\Database\Expression\QueryExpression
310310
*/
311311
public function or_($conditions, $types = []) {
312-
if (is_callable($conditions)) {
312+
if (!is_string($conditions) && is_callable($conditions)) {
313313
return $conditions(new self([], $this->typeMap()->types($types), 'OR'));
314314
}
315315
return new self($conditions, $this->typeMap()->types($types), 'OR');

src/Database/Query.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public function traverse(callable $visitor, array $parts = []) {
245245
* @return $this
246246
*/
247247
public function select($fields = [], $overwrite = false) {
248-
if (is_callable($fields)) {
248+
if (!is_string($fields) && is_callable($fields)) {
249249
$fields = $fields($this);
250250
}
251251

@@ -486,7 +486,7 @@ public function join($tables = null, $types = [], $overwrite = false) {
486486
$t = ['table' => $t, 'conditions' => $this->newExpr()];
487487
}
488488

489-
if (is_callable($t['conditions'])) {
489+
if (!is_string($t['conditions']) && is_callable($t['conditions'])) {
490490
$t['conditions'] = $t['conditions']($this->newExpr(), $this);
491491
}
492492

@@ -1557,7 +1557,7 @@ protected function _decorateStatement($statement) {
15571557
protected function _conjugate($part, $append, $conjunction, $types) {
15581558
$expression = $this->_parts[$part] ?: $this->newExpr();
15591559

1560-
if (is_callable($append)) {
1560+
if (!is_string($append) && is_callable($append)) {
15611561
$append = $append($this->newExpr(), $this);
15621562
}
15631563

src/Model/Behavior/CounterCacheBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ protected function _processAssociation(Event $event, Entity $entity, Association
159159
$config = [];
160160
}
161161

162-
if (is_callable($config)) {
162+
if (!is_string($config) && is_callable($config)) {
163163
$count = $config($event, $entity, $this->_table);
164164
} else {
165165
$count = $this->_getCount($config, $countConditions);

src/Validation/ValidationRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function process($value, array $providers, array $context = []) {
155155
* @return bool True if the ValidationRule should be skipped
156156
*/
157157
protected function _skip($context) {
158-
if (is_callable($this->_on)) {
158+
if (!is_string($this->_on) && is_callable($this->_on)) {
159159
$function = $this->_on;
160160
return !$function($context);
161161
}

0 commit comments

Comments
 (0)