Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Doctrine\Orm\OrderExtension fails on SortDirection

Open Beginner friendly
#8,660 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@nozarashi20 is already working on this.

Since Oct 10, 2026.

  • #8662 by @nozarashi20 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
api, databases

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from api-platform/core

All issues in api-platform/core

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.