Skip to content

Commit

Permalink
Update query building in TranslateBehavior.
Browse files Browse the repository at this point in the history
* 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 0fc9a2c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -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'])
) {
Expand Down

0 comments on commit 0fc9a2c

Please sign in to comment.