Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Config] Cached attribute changes are not detected #39988

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

Closed
digilist opened this issue Jan 26, 2021 · 3 comments
Closed

[Config] Cached attribute changes are not detected #39988

digilist opened this issue Jan 26, 2021 · 3 comments
Labels
Bug Config Help wanted Issues and PRs which are looking for volunteers to complete them. Status: Reviewed

Comments

@digilist
Copy link
Contributor

digilist commented Jan 26, 2021

Symfony version(s) affected: 5.2

Description
Changed attributes (e.g. for the SerializedName or Groups attributes) are not detected and the config cache is not renewed.

How to reproduce
You get a failing test with this patch:

diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php
index 2bbc95ee61..42a4fc5d22 100644
--- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php
+++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php
@@ -151,6 +151,10 @@ EOPHP;
             yield [0, 9, 'private string $priv;'];
         }
 
+        if (\PHP_VERSION_ID >= 80000) {
+            yield [1, 10, '#[SomeAttribute()]'];
+        }
+
         yield [1, 17, 'public function ccc($bar = 187) {}'];
         yield [1, 17, 'public function ccc($bar = ANOTHER_ONE_THAT_WILL_NEVER_BE_DEFINED_CCCCCCCCC) {}'];
         yield [1, 17, null, static function () { \define('A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC', 'foo'); }];

Possible Solution
Consider the attributes while building the file hash.

Additional context
It seems like ReflectionMethod::__toString() does not include information about attributes. I am not sure if this is on purpose of if this is missing. (Also, ReflectionAttribute does not have a __toString() method like the other reflection classes have).
See https://3v4l.org/Ht9pi

Maybe this needs to be adjusted in PHP as well (not sure about that).

@YaFou
Copy link
Contributor

YaFou commented Jan 26, 2021

Status: reviewed

I will try to work on a fix.

@digilist
Copy link
Contributor Author

Great, thank you! I also wrote an email to PHP Internals to ask whether this is an issue that should be fixed in PHP: https://externals.io/message/112999

@nicolas-grekas
Copy link
Member

This would also be useful as in eg #39897 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Config Help wanted Issues and PRs which are looking for volunteers to complete them. Status: Reviewed
Projects
None yet
Development

No branches or pull requests

4 participants