-
Notifications
You must be signed in to change notification settings - Fork 0
Component object fingerprint value #8
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
Conversation
36f146c to
e49933a
Compare
kbond
left a comment
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.
Just a few minor things.
|
|
||
| public function calculateFingerprint(array $data): string | ||
| { | ||
| return base64_encode(hash_hmac('sha256', serialize($data), $this->secret, true)); |
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 is all internal so we can change later but maybe we should create a ChecksumCalculator object that's used for calculating the checksum and the fingerprint?
In a future PR, will you need to verify the fingerprint?
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.
I'm going to save for later, but you're right.
Related, it's odd to have to pass the $secret into DehydratedComponent. Probably there should be a DehydratedComponentFactory and some of the DehydratedComponent logic (i.e. public static function createFromCombinedData and the checksum creation) should be moved there.
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.
Yeah, a new ChecksumCalculator would contain the secret - once we have this service, it will probably require some refactoring of DehydratedComponent.
|
Merged in now - thanks for the review :) |
symfony#500
The reason for this is explained by the same flow:
A) Component parent renders & all children are given a "fingerprint" (this PR!) that is a checksum of the "input" passed to create that child
B) On parent re-render, an array containing [{ id: 'the-child-id', fingerprint: 'its fingerprint'}, ... ] is sent along with the parent component data.
C) We will (still a TODO - 6 on the linked PR) use that info to figure out if the "fingerprint" of any specific children has changed (i.e. we calculate the deterministic id of a child component, find its fingerprint using that id from the data above, and compare).