Skip to content

Commit

Permalink
Removed duplicate variable
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jun 10, 2013
1 parent 536d2cb commit 331b65d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/Cake/ORM/Association/BelongsToMany.php
Expand Up @@ -235,10 +235,9 @@ protected function _buildQuery($options) {

if (!empty($options['fields'])) {
$fields = $fetchQuery->aliasFields($options['fields'], $alias);
$required = $pivotAlias . '.' . $options['foreignKey'];
if (!in_array($required, $fields)) {
if (!in_array($key, $fields)) {
throw new \InvalidArgumentException(
sprintf('You are required to select the "%s" field', $required)
sprintf('You are required to select the "%s" field', $key)
);
}
$fetchQuery->select($fields);
Expand Down
5 changes: 2 additions & 3 deletions lib/Cake/ORM/Association/ExternalAssociationTrait.php
Expand Up @@ -179,10 +179,9 @@ protected function _buildQuery($options) {

if (!empty($options['fields'])) {
$fields = $fetchQuery->aliasFields($options['fields'], $alias);
$required = $alias . '.' . $options['foreignKey'];
if (!in_array($required, $fields)) {
if (!in_array($key, $fields)) {
throw new \InvalidArgumentException(
sprintf('You are required to select the "%s" field', $required)
sprintf('You are required to select the "%s" field', $key)
);
}
$fetchQuery->select($fields);
Expand Down

0 comments on commit 331b65d

Please sign in to comment.