Skip to content

Commit

Permalink
Merge branch '5.x' into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 15, 2025
2 parents 347974a + 9f4b705 commit 15ab223
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 5

## Unreleased

- Fixed an error that could occur when setting `relatedTo*` GraphQL arguments to `null`. ([#16433](https://github.com/craftcms/cms/issues/16433))

## 5.5.10 - 2025-01-14

- Fixed a bug where the control panel could display a notice about the Craft CMS license belonging to a different domain, even when accessing the control panel from the correct domain. ([#16396](https://github.com/craftcms/cms/issues/16396))
Expand Down
10 changes: 10 additions & 0 deletions src/gql/ArgumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use craft\errors\GqlException;
use craft\events\RegisterGqlArgumentHandlersEvent;
use craft\gql\base\ArgumentHandlerInterface;
use craft\gql\base\RelationArgumentHandler;
use craft\gql\handlers\RelatedAssets;
use craft\gql\handlers\RelatedCategories;
use craft\gql\handlers\RelatedEntries;
Expand Down Expand Up @@ -153,6 +154,15 @@ public function prepareArguments(array $arguments): array
if (!empty($arguments[$argumentName]) && $handler instanceof ArgumentHandlerInterface) {
$arguments = $handler->handleArgumentCollection($arguments);
}
// if it's one of the relatedToXYZ arguments,
// if the value is empty/null unset that arg so that it doesn't go into the criteria
if (
array_key_exists($argumentName, $arguments) &&
empty($arguments[$argumentName]) &&
$handler instanceof RelationArgumentHandler
) {
unset($arguments[$argumentName]);
}
}

return $arguments;
Expand Down

0 comments on commit 15ab223

Please sign in to comment.