APY / APYDataGridBundle

Symfony Datagrid Bundle
MIT License
492 stars 344 forks source link

Compatibility Issue with Symfony 3.4 and `getRootNode()` Method in `TreeBuilder` #1110

Open vialcollet opened 1 month ago

vialcollet commented 1 month ago

Description: We encountered a fatal error when trying to clear the cache after updating to APY/DataGridBundle version 4.0 on a Symfony 3.4 project. The issue seems to be due to the getRootNode() method in the TreeBuilder class, which does not exist in Symfony 3.4.

Error Message:

Fatal error: Uncaught Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "getRootNode" of class "Symfony\Component\Config\Definition\Builder\TreeBuilder". in /srv/app/vendor/apy/datagrid-bundle/DependencyInjection/Configuration.php:21

Steps to Reproduce:

  1. Start with a Symfony 3.4 project.
  2. Require APY/DataGridBundle version 4.0 using Composer.
  3. Run composer update.
  4. Attempt to clear the cache using php bin/console cache:clear --no-warmup.
  5. Observe the fatal error.

Expected Behavior: The bundle should either be compatible with Symfony 3.4, or the composer.json file should specify a Symfony version requirement that prevents installation on incompatible versions.

Actual Behavior: The bundle attempts to use getRootNode(), which is available from Symfony 4.2 onwards, thus causing a fatal error in Symfony 3.4 environments.

Possible Solutions:

  1. Update the composer.json to reflect the correct Symfony version requirements.
  2. Adjust the Configuration.php to check for Symfony version and use either getRootNode() or the deprecated root() method accordingly.

Additional Context: Updating to a newer version of Symfony might not be feasible for all projects immediately due to extensive dependencies and potential backward compatibility issues. A clarification in the documentation or adjustment in the code to maintain backward compatibility would be beneficial for developers relying on older Symfony versions.

Thank you for looking into this issue. Any guidance or updates on how to handle or patch this would be greatly appreciated.