This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier c2a6e37ad7 merged branch Crell/route-serialize (PR #4755)
Commits
-------

a6d44bd When serializing a Route, don't serialize the compiled route.

Discussion
----------

When serializing a Route, don't serialize the compiled route.

The compiled route typically has a reference to the Route.  The Route of course has a reference to the compiled route.  This is a circular reference.  That can sometimes cause issues, say for var_export().  I ran into this issue while serializing route objects, but it could happen in other cases, too.

In any event, since the compiled route object is simply derived data I see no reason to keep it around.  If we serialize a Route, we just want the basic route information.  We can recompile later if needs be.  As a nice side-effect, this makes the serialized string much smaller.

---------------------------------------------------------------------------

by stof at 2012-07-04T21:09:34Z

I would implement the Serializable interface instead. It would be more consistent with what Symfony does elsewhere, and would avoid breaking things when you extend the class (Silex does it). Private properties cannot be accessed from the child class, and this is what PHP tries to do when you use ``__sleep`` as you only return the property name.

---------------------------------------------------------------------------

by Tobion at 2012-07-04T22:52:00Z

I also saw this circular reference. Maybe it's time to remove the reference from compiled route to the original route?!
If a developer needs the original route, he should keep the reference himself. No need to do it for him. It's like offering a "decompiling" reference that shouldnt be there.

---------------------------------------------------------------------------

by Crell at 2012-07-05T00:08:51Z

With Serializable, I'd have to reimplement serialize() myself, wouldn't I?  I just want to exclude the one value, but otherwise serialize normally.  Seems like that would be a non-small amount of work compared to a one-liner.

---------------------------------------------------------------------------

by stof at 2012-07-05T00:09:44Z

@Crell you have to reimplement it in the child class only if you want to add more stuff in the serialized data.

and breaking Silex just to be lazy here is not a good idea

---------------------------------------------------------------------------

by Crell at 2012-07-05T00:24:52Z

I'm not trying to break Silex. :-P

I think this is what you mean, but I'm not sure that completely changing the serialized form (which this does) is wise.  Is that not also a BC break of sorts?

Once we settle on one we can cherry-pick out the commits we want.

---------------------------------------------------------------------------

by stof at 2012-07-05T01:00:29Z

changing the serialization format is not an issue: the only place where serialized routes are likely to be stored is in the cache, and the cache does not need to be BC between 2.0 and 2.1. The user already have to delete it due to other changes.

---------------------------------------------------------------------------

by fabpot at 2012-07-09T15:02:59Z

+1 for implementing `Serializable`. Can you squash your commits and fix the CS (we need 4 spaces)? Thanks.

---------------------------------------------------------------------------

by Crell at 2012-07-10T03:25:04Z

Squshed, Spaced, and Rebased.
2012-07-10 07:44:57 +02:00
src/Symfony When serializing a Route, don't serialize the compiled route. 2012-07-09 22:23:40 -05:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore ignore composer.phar 2012-04-20 14:10:06 +01:00
.travis.yml merged 2.0 2012-05-30 13:44:37 +02:00
autoload.php.dist removed unneeded code 2012-06-30 16:47:41 +02:00
CHANGELOG-2.0.md updated CHANGELOG for 2.0.14 2012-05-17 18:29:55 +02:00
composer.json Changed the minimum stability to dev for the testsuite 2012-07-04 18:43:06 +02:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.0.14 2012-05-17 18:30:22 +02:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
phpunit.xml.dist Set init.default_locale to 'en' in phpunit.xml.dist 2012-05-11 09:33:42 +02:00
README.md updated minimum PHP version to 5.3.3 2012-05-07 10:29:11 +02:00
UPGRADE-2.1.md [Form] Prevented duplicate validation of form constraints 2012-07-09 19:28:39 +02:00

README

Build Status

What is Symfony2?

Symfony2 is a PHP 5.3 full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Requirements

Symfony2 is only supported on PHP 5.3.3 and up.

Installation

The best way to install Symfony2 is to download the Symfony Standard Edition available at http://symfony.com/download.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony2 can help speed up your development and take the quality of your work to the next level, read the official Symfony2 documentation.

Contributing

Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section.