Skip to content

Commit

Permalink
Normalize variable type
Browse files Browse the repository at this point in the history
Make sure $query['conditions'] is an array in beforeFind() callback, so as to avoid a PHP warning when using array_keys()
  • Loading branch information
Matt Alexander committed Jul 18, 2011
1 parent fbbb4b0 commit 7539abc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions models/behaviors/habtamable.php
Expand Up @@ -52,6 +52,9 @@ public function beforeFind(&$Model, $query) {
* and implode the keys it into a string.
*/
private function checkHabtmConditions($Model, $query) {
if (empty($query['conditions'])) {
$query['conditions'] = array();
}
$searchableConditions = implode('.', Set::flatten(array_keys($query['conditions'])));

return (bool) strpos($searchableConditions, $this->settings[$Model->alias]['habtmModel']);
Expand Down

0 comments on commit 7539abc

Please sign in to comment.