Skip to content

Commit 1c0b6c0

Browse files
darxmacmarkstory
authored andcommitted
Update afterSave to ensure created entires have all translated fields present
Without all fields being present, find() will be unable to find the translated records. Fixes #3009
1 parent ed4493d commit 1c0b6c0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Cake/Model/Behavior/TranslateBehavior.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,16 @@ public function afterSave(Model $model, $created) {
392392
unset($this->runtime[$model->alias]['beforeValidate'], $this->runtime[$model->alias]['beforeSave']);
393393
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
394394
$RuntimeModel = $this->translateModel($model);
395+
396+
$fields = array_merge($this->settings[$model->alias], $this->runtime[$model->alias]['fields']);
397+
if ($created) {
398+
foreach ($fields as $field) {
399+
if (!isset($tempData[$field])) {
400+
//set the field value to an empty string
401+
$tempData[$field] = '';
402+
}
403+
}
404+
}
395405

396406
foreach ($tempData as $field => $value) {
397407
unset($conditions['content']);

0 commit comments

Comments
 (0)