stof / StofDoctrineExtensionsBundle

Integration bundle for DoctrineExtensions by l3pp4rd in Symfony
https://symfony.com/bundles/StofDoctrineExtensionsBundle/current/index.html
MIT License
1.89k stars 380 forks source link

Sort error when using Repository functions #445

Closed dotstormz closed 1 year ago

dotstormz commented 1 year ago

Describe the bug I have implemented the Tree NestedSet behaviour as outlined in the Gedmo Doctrine Extensions repository (https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/tree.md).

Unfortunately following the documentation yields the following error: Invalid sort options specified: field - root, direction - asc. When taking the executed queries from the debug bar and manually executing an SQL query I can see that the query to retrieve data is relatively simple and follows the expected response of a nested set query. The issue seems to be code related.

I am using Symfony 6.1.4, PHP 8.1.8, Gedmo 3.8.0, Stof 1.7.0

I am not doing anything fanciful my code follows the examples within the documentation.

There is another report of the same error at: https://stackoverflow.com/questions/73580608/symfonys-gedmo-tree-throws-sorting-error

To Reproduce Steps to reproduce the behavior:

  1. Follow the guide to implement the Category entity with PHP8 attributes
  2. Run doctrine migrations to have the necessary DB tables created
  3. Add tree data via the Entity Manger and persist
  4. Attempt to use the childrenHierarchy function in any example within the documentation

Expected behavior Either a multidimensional array of tree items or alternatively if you decide to decorate the free, a HTML version of the Nested Set.

Additional context I am unsure whether the fault here is in the Doctrine Extensions library of the implementation of the bundle.

stof commented 1 year ago

This should be reported to https://github.com/doctrine-extensions/DoctrineExtensions as that's where all the logic is implemented