Skip to content

Commit

Permalink
Fix issue with find(count) and TranslateBehavior.
Browse files Browse the repository at this point in the history
Fixes #2667
  • Loading branch information
markstory committed Jan 19, 2014
1 parent 7a27650 commit 55e1619
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -305,7 +305,7 @@ public function afterFind(Model $Model, $results, $primary = false) {
}
} else {
$value = '';
if (is_numeric($row[$Model->alias][$aliasVirtual]) || !empty($row[$Model->alias][$aliasVirtual])) {
if (isset($row[$Model->alias][$aliasVirtual])) {
$value = $row[$Model->alias][$aliasVirtual];
}
$row[$Model->alias][$aliasField] = $value;
Expand Down
10 changes: 7 additions & 3 deletions lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
Expand Up @@ -285,7 +285,9 @@ public function testLocaleSingleCountWithConditions() {

$TestModel = new TranslatedItem();
$TestModel->locale = 'eng';
$result = $TestModel->find('all', array('conditions' => array('slug' => 'first_translated')));
$result = $TestModel->find('all', array(
'conditions' => array('slug' => 'first_translated')
));
$expected = array(
array(
'TranslatedItem' => array(
Expand All @@ -300,10 +302,12 @@ public function testLocaleSingleCountWithConditions() {
);
$this->assertEquals($expected, $result);

$result = $TestModel->find('count', array('conditions' => "TranslatedItem.slug = 'first_translated'"));
$result = $TestModel->find('count', array(
'conditions' => array('slug' => 'first_translated')
));
$expected = 1;
$this->assertEquals($expected, $result);
}
}

/**
* testLocaleSingleAssociations method
Expand Down

0 comments on commit 55e1619

Please sign in to comment.