Permalink
Browse files

Update query building in TranslateBehavior.

* Reduce duplicate checks for Alias.*.
* Allow both the quoted and non quoted version of Alias.*

Fixes #3210
  • Loading branch information...
markstory committed Sep 26, 2012
1 parent 6818d69 commit 0fc9a2c29c489177afeecaccf4eb7ddb7ab153a7
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/Cake/Model/Behavior/TranslateBehavior.php
@@ -147,11 +147,14 @@ public function beforeFind(Model $Model, $query) {
if (empty($query['fields'])) {
$addFields = $fields;
} elseif (is_array($query['fields'])) {
$isAllFields = (
in_array($Model->alias . '.' . '*', $query['fields']) ||
in_array($Model->escapeField('*'), $query['fields'])
);
foreach ($fields as $key => $value) {
$field = (is_numeric($key)) ? $value : $key;
if (
in_array($Model->escapeField('*'), $query['fields']) ||
$isAllFields ||
in_array($Model->alias . '.' . $field, $query['fields']) ||
in_array($field, $query['fields'])
) {

0 comments on commit 0fc9a2c

Please sign in to comment.