Skip to content

Remove http_cache.invalidation deprecation and fix some remaining deprec#3276

Merged
soyuka merged 4 commits into
api-platform:masterfrom
dunglas:fix-deprecations
Apr 9, 2020
Merged

Remove http_cache.invalidation deprecation and fix some remaining deprec#3276
soyuka merged 4 commits into
api-platform:masterfrom
dunglas:fix-deprecations

Conversation

@dunglas

@dunglas dunglas commented Nov 19, 2019

Copy link
Copy Markdown
Member
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

Comment thread src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php
@soyuka soyuka force-pushed the fix-deprecations branch 4 times, most recently from 811c1f8 to c6310d3 Compare March 30, 2020 12:20
Comment thread tests/Fixtures/app/config/config_common.yml
@@ -169,24 +169,24 @@ private function registerCommonConfiguration(ContainerBuilder $container, array
$container->setParameter('api_platform.collection.exists_parameter_name', $config['collection']['exists_parameter_name']);
$container->setParameter('api_platform.collection.order', $config['collection']['order']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed, no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, not sure yet if we should deprecate these parameters?

pagination_client_items_per_page: true
pagination_client_partial: true
pagination_items_per_page: 3
order_parameter_name: 'order'

@teohhanhui teohhanhui Mar 30, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no such key supported in the defaults. In fact, all the _parameter_name attributes are not there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 in fact the defaults are meant to be used on the @ApiResource (IIUC) and parameter names are supposed to be globally defined ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter names are customizable per-filter, so indeed they have no place in the resource / operation attributes, I think...

return;
}
if (\is_string($defaultOrder)) {
$this->order = $defaultOrder;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@soyuka soyuka force-pushed the fix-deprecations branch from c6310d3 to 690c28c Compare April 3, 2020 09:22
@soyuka soyuka force-pushed the fix-deprecations branch 4 times, most recently from f3b8f52 to a5b0d4c Compare April 9, 2020 17:39
@soyuka soyuka force-pushed the fix-deprecations branch from a5b0d4c to fbfa615 Compare April 9, 2020 17:58
@soyuka soyuka merged commit dc461fc into api-platform:master Apr 9, 2020
@soyuka

soyuka commented Apr 9, 2020

Copy link
Copy Markdown
Member

Note that #3472 will improve this

$container->setParameter('api_platform.eager_loading.force_eager', $config['eager_loading']['force_eager']);
$container->setParameter('api_platform.collection.exists_parameter_name', $config['collection']['exists_parameter_name']);
$container->setParameter('api_platform.collection.order', $config['collection']['order']);
$container->setParameter('api_platform.collection.order', $config['defaults']['order'] ?? $config['collection']['order']);

@guilliamxavier guilliamxavier Mar 26, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was wrong! defaults.order is supposed to be the global resource default for https://api-platform.com/docs/core/default-order/#overriding-default-order i.e. an array like {"foo":"ASC"} or ["foo", "bar"], not to be confused with collection.order that is a string "ASC" or "DESC"!

I first wrote this:

api_platform:
    defaults:
        order: [createdAt, id]

but got this error:

Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\OrderExtension::__construct() must be of the type string or null, array given

Fortunately I could work around by using the longer:

api_platform:
    defaults:
        attributes:
            order: [createdAt, id]

but still...

Can this change be reverted as a bug fix or would it be a BC break now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's more a bugfix since this change is wrong.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I opened #4170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants