Skip to content

[Cache] Prevent fatal errors on php 8 when running concurrently with TagAwareAdapter v6.1 #46143

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
Apr 25, 2022

Conversation

sbelyshkin
Copy link
Contributor

Q A
Branch? 4.4 - 5.3
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR

This fix prevents fatal errors which may arise during rolling updates when TagAwareAdapter is upgraded from versions prior to 5.4 to the latest 6.1. TypeErrors occur because of different value types for tag versions and rules for numeric strings in php 8.x https://www.php.net/manual/en/language.types.numeric-strings.php

@sbelyshkin sbelyshkin force-pushed the prevent-fatal-errors branch from 84a0b75 to 22c3afd Compare April 22, 2022 09:37
@@ -430,6 +433,10 @@ private function getTagVersions(array $tagsByKey, array &$invalidatedTags = [])
if (isset($invalidatedTags[$tag])) {
$invalidatedTags[$tag] = $version->set(++$tagVersions[$tag]);
}
if (!\is_int($tagVersions[$tag])) {
Copy link
Member

Choose a reason for hiding this comment

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

on the line above, we have a ++ on this entry, shouldn't we check for this earlier?

Copy link
Contributor Author

@sbelyshkin sbelyshkin Apr 22, 2022

Choose a reason for hiding this comment

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

++ operator works with strings
Although it not always changes string values (and thus no invalidation occurs in those cases) but at least it doesn't do the fatality.

@xabbuh
Copy link
Member

xabbuh commented Apr 22, 2022

Can we add a test to prevent future regressions?

@sbelyshkin sbelyshkin force-pushed the prevent-fatal-errors branch from 22c3afd to 0f085c4 Compare April 22, 2022 14:49
@sbelyshkin
Copy link
Contributor Author

I've added a few tests. Please let me know if they make sense.

@sbelyshkin sbelyshkin force-pushed the prevent-fatal-errors branch from 0f085c4 to 33790b3 Compare April 25, 2022 03:16
@nicolas-grekas nicolas-grekas changed the title [Cache] Prevent fatal errors in php 8.x [Cache] Prevent fatal errors on php 8 when running concurrently with v6.1 Apr 25, 2022
@nicolas-grekas nicolas-grekas changed the title [Cache] Prevent fatal errors on php 8 when running concurrently with v6.1 [Cache] Prevent fatal errors on php 8 when running concurrently with TagAwareAdapter v6.1 Apr 25, 2022
@nicolas-grekas
Copy link
Member

Thank you @sbelyshkin.

@nicolas-grekas nicolas-grekas merged commit ff578de into symfony:4.4 Apr 25, 2022
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.

4 participants