Skip to content

[HttpKernel] Add #[Cache()] to describe the default HTTP cache headers on controllers #46880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2022

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Part of #44705
License MIT
Doc PR -

Extracted from #45415 (and modernized a lot).

I'd appreciate any help for porting the other attributes following this leading PR 🙏

@carsonbot carsonbot added this to the 6.2 milestone Jul 7, 2022
@carsonbot carsonbot changed the title [HttpKernel] Add #[Cache] to describe the default HTTP cache headers on controllers [Cache][HttpKernel] Add # to describe the default HTTP cache headers on controllers Jul 7, 2022
@nicolas-grekas nicolas-grekas changed the title [Cache][HttpKernel] Add # to describe the default HTTP cache headers on controllers [Cache][HttpKernel] Add #[Cache] to describe the default HTTP cache headers on controllers Jul 7, 2022
@carsonbot carsonbot changed the title [Cache][HttpKernel] Add #[Cache] to describe the default HTTP cache headers on controllers [HttpKernel] Add # to describe the default HTTP cache headers on controllers Jul 7, 2022
@nicolas-grekas nicolas-grekas changed the title [HttpKernel] Add # to describe the default HTTP cache headers on controllers [HttpKernel] Add #[Cache()] to describe the default HTTP cache headers on controllers Jul 7, 2022
@nicolas-grekas nicolas-grekas force-pushed the hk-cache-attr branch 3 times, most recently from e993a98 to 35e176a Compare July 7, 2022 15:42
@nicolas-grekas nicolas-grekas force-pushed the hk-cache-attr branch 2 times, most recently from 4a33e21 to a8efdea Compare July 9, 2022 07:52
@nicolas-grekas nicolas-grekas force-pushed the hk-cache-attr branch 4 times, most recently from 421a733 to a63b607 Compare July 12, 2022 07:44
@nicolas-grekas nicolas-grekas force-pushed the hk-cache-attr branch 2 times, most recently from 076916f to 7bc1513 Compare July 12, 2022 12:52
@@ -61,7 +61,7 @@ public function setController(callable $controller, array $attributes = null): v
unset($this->attributes);
}

$action = new \ReflectionFunction($controller(...));
$action = \is_array($controller) ? new \ReflectionMethod(...$controller) : (\is_string($controller) && str_contains($controller, '::') ? new \ReflectionMethod($controller) : new \ReflectionFunction($controller(...)));
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed to work around php/php-src#8982

@chalasr
Copy link
Member

chalasr commented Jul 12, 2022

Thank you @nicolas-grekas.

@chalasr chalasr merged commit 96667d3 into symfony:6.2 Jul 12, 2022
@fabpot fabpot deleted the hk-cache-attr branch July 12, 2022 15:34
chalasr added a commit that referenced this pull request Jul 14, 2022
…stenerTest explicitly (derrabus)

This PR was merged into the 6.2 branch.

Discussion
----------

[HttpKernel] Declare properties used by CacheAttributeListenerTest explicitly

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | N/A

A test case introduced by #46880 triggers deprecation notices on PHP 8.2 because none of the properties used is declared. This PR fixes the build by adding explicit property declarations.

Commits
-------

f0d0799 [HttpKernel] Declare properties used by CacheAttributeListenerTest explicitly
@fabpot fabpot mentioned this pull request Oct 24, 2022
fabpot added a commit to sensiolabs/SensioFrameworkExtraBundle that referenced this pull request Nov 1, 2022
This PR was merged into the 6.1.x-dev branch.

Discussion
----------

Check _cache type for compatibility with Symfony 6.2

The new `#[Cache()]` attribute that is added to Symfony 6.2 (symfony/symfony#46880) is stored in the same request attribute `_cache`.

Before this change, if the bundle is enabled and Symfony's Cache attribute is used, we get an error.

```
Call to a member function getSMaxAge() on array
```

This bugfix will ease migration when simultaneously usage of FrameworkExtraBundle and Symfony attributes is necessary.

Commits
-------

0fd5fdf Check _cache type for compatibility with Symfony 6.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants