Skip to content

Bug when using defaults.pagination_enabled to configure pagination #3992

@emmanuelballery

Description

@emmanuelballery

API Platform version(s) affected: 2.6.1

Description

Following deprecation recommandation:

->setDeprecated(...$this->buildDeprecationArgs('2.6', 'The use of the `collection.pagination.enabled` has been deprecated in 2.6 and will be removed in 3.0. Use `defaults.pagination_enabled` instead.'))

If you use the defaults.pagination_enabled to configure your pagination (instead of api_platform.collection.pagination.enabled) then an error occurs:

Argument 2 passed to Symfony\Component\DependencyInjection\Extension\Extension::isConfigEnabled() must be of the type array, bool given, called in /var/www/jarvis/vendor/api-platform/core/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php on line 188

How to reproduce

Configure pagination using defaults.pagination_enabled:

api_platform:
    defaults:
        pagination_enabled: true

Possible Solution

The call to isConfigEnabled requires the argument 2 to be an array, not a boolean:

$container->setParameter('api_platform.collection.pagination.enabled', $this->isConfigEnabled($container, $config['defaults']['pagination_enabled'] ?? $config['collection']['pagination']));

This should be:

$container->setParameter('api_platform.collection.pagination.enabled', $config['defaults']['pagination_enabled'] ?? $this->isConfigEnabled($container,  $config['collection']['pagination']));

I'm using Symfony 4.4.* and the signature of isConfigEnabled has not changed since 8 years it seems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions