Fix issue with find(count) and TranslateBehavior.

Fixes #2667
This commit is contained in:
mark_story 2014-01-18 21:54:09 -05:00
parent 7a27650297
commit 55e1619c59
2 changed files with 8 additions and 4 deletions

View file

@ -305,7 +305,7 @@ class TranslateBehavior extends ModelBehavior {
}
} 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;

View file

@ -285,7 +285,9 @@ class TranslateBehaviorTest extends CakeTestCase {
$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(
@ -300,10 +302,12 @@ class TranslateBehaviorTest extends CakeTestCase {
);
$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