Skip to content

Commit

Permalink
Removing function from created virtual fields in translate behavior a…
Browse files Browse the repository at this point in the history
…s it was not needed
  • Loading branch information
lorenzo committed Oct 26, 2010
1 parent 90274ef commit 0263569
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cake/libs/model/behaviors/translate.php
Expand Up @@ -142,7 +142,10 @@ public function beforeFind(&$model, $query) {

if (is_array($locale)) {
foreach ($locale as $_locale) {
$model->virtualFields['_i18n_'.$field.'_'.$_locale] = 'COALESCE('. 'I18n__'.$field.'__'.$_locale.'.content, NULL)';
$model->virtualFields['i18n_'.$field.'_'.$_locale] = 'I18n__'.$field.'__'.$_locale.'.content';
if (!empty($query['fields'])) {
$query['fields'][] = 'i18n_'.$field.'_'.$_locale;
}
$query['joins'][] = array(
'type' => 'LEFT',
'alias' => 'I18n__'.$field.'__'.$_locale,
Expand All @@ -156,7 +159,10 @@ public function beforeFind(&$model, $query) {
);
}
} else {
$model->virtualFields['_i18n_'.$field] = 'COALESCE('. 'I18n__'.$field.'.content, NULL)';
$model->virtualFields['i18n_'.$field] = 'I18n__'.$field.'.content';
if (!empty($query['fields'])) {
$query['fields'][] = 'i18n_'.$field;
}
$query['joins'][] = array(
'type' => 'LEFT',
'alias' => 'I18n__'.$field,
Expand Down Expand Up @@ -189,7 +195,8 @@ public function beforeFind(&$model, $query) {
* @return array Modified results
*/
public function afterFind(&$model, $results, $primary) {
$this->runtime[$model->alias]['fields'] = array();
$model->virtualFields = $this->runtime[$model->alias]['virtualFields'];
$this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array();
$locale = $this->_getLocale($model);

if (empty($locale) || empty($results) || empty($this->runtime[$model->alias]['beforeFind'])) {
Expand Down

0 comments on commit 0263569

Please sign in to comment.