-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Form] Reset cache when AbstractTypeExtension::getExtendedTypes change
#62804
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
base: 6.4
Are you sure you want to change the base?
Conversation
|
I don't think we should create new resource types. The existing |
| { | ||
| $hash = hash_init('xxh128'); | ||
|
|
||
| $ret = ($this->staticMethod)(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is broken. When calling it in isFresh on an unserialized data, you cannot assume that this method still exists (and is still static). The check needs to handle gracefully the case where the code was changed (as that's precisely the use case for having such resource)
I guess you are talking about It won't work though, will it? It only checks the public/protected API. Here, we must execute the method and retrieve the data. |
|
ah indeed. I guess the reason why |
| private string $hash; | ||
|
|
||
| /** | ||
| * @param array $staticMethod A callable represented as [className, methodName] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param array $staticMethod A callable represented as [className, methodName] | |
| * @param array{string, string} $staticMethod A callable represented as [className, methodName] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe we should even have 2 parameters instead of this array.
| * @param array $staticMethod A callable represented as [className, methodName] | ||
| */ | ||
| public function __construct( | ||
| private $staticMethod, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should have an array type.
|
|
||
| public function __toString(): string | ||
| { | ||
| return 'static_method_resource'.$this->staticMethod[0].'::'.$this->staticMethod[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return 'static_method_resource'.$this->staticMethod[0].'::'.$this->staticMethod[1]; | |
| return 'static_method_resource:'.$this->staticMethod[0].'::'.$this->staticMethod[1]; |
This will be more readable in case this is investigated, by having a delimiter before the class name.
|
|
||
| public function __unserialize(array $data): void | ||
| { | ||
| $this->hash = array_shift($data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using array_shift, it should access the keys in the array as __serialize returns an associative array.
|
|
||
| $ret = ($this->staticMethod)(); | ||
|
|
||
| if (is_iterable($ret)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this special case for iterable ?
And why ignoring the keys in that iterable (which will make this unusable for RegisterListenersPass) ?
AbstractTypeExtension::getExtendedTypes change
Not finished, obviously. But is this the way to go?