Skip to content

Commit 55e1619

Browse files
committed
Fix issue with find(count) and TranslateBehavior.
Fixes #2667
1 parent 7a27650 commit 55e1619

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/Cake/Model/Behavior/TranslateBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public function afterFind(Model $Model, $results, $primary = false) {
305305
}
306306
} else {
307307
$value = '';
308-
if (is_numeric($row[$Model->alias][$aliasVirtual]) || !empty($row[$Model->alias][$aliasVirtual])) {
308+
if (isset($row[$Model->alias][$aliasVirtual])) {
309309
$value = $row[$Model->alias][$aliasVirtual];
310310
}
311311
$row[$Model->alias][$aliasField] = $value;

lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ public function testLocaleSingleCountWithConditions() {
285285

286286
$TestModel = new TranslatedItem();
287287
$TestModel->locale = 'eng';
288-
$result = $TestModel->find('all', array('conditions' => array('slug' => 'first_translated')));
288+
$result = $TestModel->find('all', array(
289+
'conditions' => array('slug' => 'first_translated')
290+
));
289291
$expected = array(
290292
array(
291293
'TranslatedItem' => array(
@@ -300,10 +302,12 @@ public function testLocaleSingleCountWithConditions() {
300302
);
301303
$this->assertEquals($expected, $result);
302304

303-
$result = $TestModel->find('count', array('conditions' => "TranslatedItem.slug = 'first_translated'"));
305+
$result = $TestModel->find('count', array(
306+
'conditions' => array('slug' => 'first_translated')
307+
));
304308
$expected = 1;
305309
$this->assertEquals($expected, $result);
306-
}
310+
}
307311

308312
/**
309313
* testLocaleSingleAssociations method

0 commit comments

Comments
 (0)