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

Skip to content

[ExpressionLanguage] Fix BC of cached SerializedParsedExpression containing GetAttrNode #48559

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
Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,15 @@ public function toArray()
return [$this->nodes['node'], '[', $this->nodes['attribute'], ']'];
}
}

/**
* Provides BC with instances serialized before v6.2
*/
public function __unserialize(array $data): void
{
$this->nodes = $data['nodes'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolas-grekas I'm wondering if there's a way to just call the "default PHP unserialization" in one line and then add the extra checks?

Copy link
Member

Choose a reason for hiding this comment

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

use __wakeup instead?

Copy link
Member

Choose a reason for hiding this comment

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

on a closer look, the code is correct (except for isNullCoalesce which has never been part of any serialized payloads)

$this->attributes = $data['attributes'];
$this->attributes['is_null_coalesce'] ??= false;
$this->attributes['is_short_circuited'] ??= $data["\x00Symfony\Component\ExpressionLanguage\Node\GetAttrNode\x00isShortCircuited"] ?? false;
}
}