Skip to content

Commit

Permalink
[Bug][BC] Filters should be merged with user's ones instead of overri…
Browse files Browse the repository at this point in the history
…ding
  • Loading branch information
tunecino committed May 31, 2019
1 parent b35827d commit d0f669c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function findCurrentModels($IDs)
$getter = 'get' . $this->relationName;

$relModel = $this->getRelativeModel();
$q = $relModel->$getter()->where([$pk => $ids]);
$q = $relModel->$getter()->andWhere([$pk => $ids]);

$ci = count($ids);
$model = $ci > 1 ? $q->all() : $q->one();
Expand Down
4 changes: 2 additions & 2 deletions src/LinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public function run($IDs)

$to_link = [];
foreach ($ids as $pk_value) {
$linked = $relModel->$getter()->where([$pk => $pk_value])->exists();
$linked = $relModel->$getter()->andWhere([$pk => $pk_value])->exists();

if ($linked === false) {
$exist = $modelClass::find()->where([$pk => $pk_value])->exists();
$exist = $modelClass::find()->andWhere([$pk => $pk_value])->exists();

if ($exist === false)
throw new NotFoundHttpException(StringHelper::basename($modelClass) . " '$pk_value' not found.");
Expand Down
2 changes: 1 addition & 1 deletion src/UnlinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function run($IDs)

$to_unlink = [];
foreach ($ids as $pk_value) {
$linked = $relModel->$getter()->where([$pk => $pk_value])->exists();
$linked = $relModel->$getter()->andWhere([$pk => $pk_value])->exists();
if ($linked === true) $to_unlink []= $this->findModel($pk_value);
else throw new BadRequestHttpException(StringHelper::basename($modelClass) . " '$pk_value' not linked to ".StringHelper::basename($this->relativeClass)." '$this->relative_id'.");
}
Expand Down

0 comments on commit d0f669c

Please sign in to comment.