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
[Routing] serialize the compiled route to speed things up #12329
Conversation
'tokens' => $this->tokens, | ||
'staticPrefix' => $this->staticPrefix, | ||
'regex' => $this->regex, | ||
'pathVariables' => $this->pathVariables, |
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.
Can you use underscore names as this is what we are using everywhere else for array keys?
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.
done
* Tests that the compiled version is also serialized to prevent the overhead | ||
* of compiling it again after unserialize. | ||
*/ | ||
public function testSerializeWhenCompiled() |
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 am a bit confused about that test. As far as I read this test, I am pretty sure it should have passed without the actual patch as well.
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.
Yes it's not to test the compiled
but it ensures that we don't break the deserialization in the future.
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.
Oh wait, I thought you commented on testSerializedRepresentationKeepsWorking
.
No the test does not pass without the patch because then the compiled attributes are not equal and thus the routes are not equal.
This also makes the CompiledRoute implement Serializable in order to: 1. make the serialization format shorter 2. have no null bytes in there, which the native serializer add for private properties, and thus would complicate saving in databases etc. 3. We should add to our symfony BC promise, that only classes that implement Serializable are ensured to be deserializable correctly with serialized representations of the class in previous symfony versions.
1506011
to
fd88de7
Compare
@@ -105,12 +108,16 @@ public function serialize() | |||
'options' => $this->options, | |||
'schemes' => $this->schemes, | |||
'methods' => $this->methods, | |||
'compiled' => $this->compiled, |
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.
@fabpot this will conflict with newer branches that have a condition
, so you are aware when merging.
Thank you @Tobion. |
…(Tobion) This PR was merged into the 2.3 branch. Discussion ---------- [Routing] serialize the compiled route to speed things up | Q | A | ------------- | --- | Bug fix? | no | New feature? | not really | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12012, #12220 | License | MIT | Doc PR | - This also makes the CompiledRoute implement Serializable in order to: 1. make the serialization format shorter 2. have no null bytes in there, which the native serializer add for private properties, and thus would complicate saving in databases etc. 3. Since the Route now includes the CompiledRoute in the serialization, the CompiledRoute serialization must be consistent as well. We can only ensure that in future symfony version by implementing Serializable. We should add to our symfony BC promise, that only classes that implement Serializable are ensured to be deserializable correctly with serialized representations of the class in previous symfony versions. Commits ------- fd88de7 [Routing] serialize the compiled route to speed things up
This also makes the CompiledRoute implement Serializable in order to:
We should add to our symfony BC promise, that only classes that implement Serializable are ensured to be deserializable correctly with serialized representations of the class in previous symfony versions.