Doctrine\Orm\OrderExtension fails on SortDirection
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The exception is raised from BCHelper::sortDirection() when OrderExtension.php calls it at line 73 with a SortDirection enum instead of a string. Read the call site in src/Doctrine/Orm/Extension/OrderExtension.php, then the helper in src/Doctrine/Orm/Util/BCHelper.php. Done when a resource with order: ['name' => \SortDirection::Ascending] returns sorted results from the GetCollection endpoint without throwing.
Written by the indexing model from the issue text.
Description
API Platform version(s) affected: 5.0.3
Description
Setting the order on an ApiResource as SortDirection triggers an exception: ApiPlatform\Doctrine\Orm\Util\BCHelper::sortDirection(): Argument #1 ($direction) must be of type string, SortDirection given, called in /var/www/html/vendor/api-platform/core/src/Doctrine/Orm/Extension/OrderExtension.php on line 73
How to reproduce
Just define a resource like this:
#[ApiResource(
order: ['name' => \SortDirection::Ascending],
)]
and call the GetCollection-endpoint.
Possible Solution
The BCHelper should not be called, if a SortDirection is used.
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 987
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 80
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from api-platform/core
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
api-platform/core#8665 ·
Maintainers usually reply within 1 day
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
api-platform/core#8650 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
api-platform/core#8649 ·
Maintainers usually reply within 1 day
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
api-platform/core#8648 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
api-platform/core#8647 ·
Maintainers usually reply within 1 day
All issues in api-platform/core
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
backend bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
smarty-php/smarty#1215 ·
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day