Skip to content
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

Documented upgrading path for a major version #5155

Merged
merged 7 commits into from
May 25, 2015
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion contributing/code/bc.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Our backwards Compatibility Promise
Our Backwards Compatibility Promise
===================================

Ensuring smooth upgrades of your projects is our first priority. That's why
Expand Down
2 changes: 1 addition & 1 deletion cookbook/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The Cookbook
symfony1
templating/index
testing/index
upgrading
upgrade/index
validation/index
web_server/index
web_services/index
Expand Down
6 changes: 4 additions & 2 deletions cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@
* (email) :doc:`/cookbook/email/testing`
* (form) :doc:`/cookbook/form/unit_testing`

* **Upgrading**
* :doc:`/cookbook/upgrade/index`

* :doc:`/cookbook/upgrading`
* :doc:`/cookbook/upgrade/patch_version`
* :doc:`/cookbook/upgrade/minor_version`
* :doc:`/cookbook/upgrade/major_version`

* :doc:`/cookbook/validation/index`

Expand Down
16 changes: 16 additions & 0 deletions cookbook/upgrade/_update_all_packages.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
You may also want to upgrade the rest of your libraries. If you've done a
good job with your `version constraints`_ in ``composer.json``, you can do
this safely by running:

.. code-block:: bash

$ composer update

.. caution::

Beware, if you have some unspecific `version constraints`_ in your
``composer.json`` (e.g. ``dev-master``), this could upgrade some
non-Symfony libraries to new versions that contain backwards-compatibility
breaking changes.

.. _`version constraints`: https://getcomposer.org/doc/01-basic-usage.md#package-versions
18 changes: 18 additions & 0 deletions cookbook/upgrade/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. index::
single: Upgrading

Upgrading
=========

So a new Symfony release has come out and you want to upgrade, great! Fortunately,
because Symfony protects backwards-compatibility very closely, this *should*
be quite easy.

There are three types of upgrades, all needing a little different preparation:

.. toctree::
:maxdepth: 2

/cookbook/upgrade/patch_version
/cookbook/upgrade/minor_version
/cookbook/upgrade/major_version
Copy link
Member

Choose a reason for hiding this comment

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

Will the toctree look nice on symfony.com? Probably it's better to use a list here for which we know for sure that they have nice styles.

Copy link
Member

Choose a reason for hiding this comment

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

Never mind, I guess the text above is only here to have some contents on the page that was used before, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here is an example of a toctree: http://symfony.com/doc/current/cookbook/security/index.html

And indeed, the text above was just taken from the old article.

114 changes: 114 additions & 0 deletions cookbook/upgrade/major_version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
.. index::
single: Upgrading; Major Version

Upgrading a Major Version (e.g. 2.7.0 to 3.0.0)
===============================================

Every few years, Symfony releases a new major version release (the first number
changes). These releases are the trickiest to upgrade, as they are allowed to
contain BC breaks. However, Symfony tries to make this upgrade process as
smooth as possible.

This means that you can update most of your code before the major release is
actually released. This is called making your code *future compatible*.

There are a couple of steps to upgrading a major version:

#. :ref:`Make your code deprecation free <upgrade-major-symfony-deprecations>`;
#. :ref:`Update to the new major version via Composer <upgrade-major-symfony-composer>`.
#. :ref:`Update your code to work with the new version <upgrade-major-symfony-after>`

.. _upgrade-major-symfony-deprecations:

1) Make your Code Deprecation Free
Copy link
Member

Choose a reason for hiding this comment

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

Your

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

During the lifecycle of a major release, new features are added and method
signatures and public API usages are changed. However, minor versions should
Copy link
Member

Choose a reason for hiding this comment

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

link minor versions to the upgrade minor versions, in case I don't remember what a "minor version" is

not contain any backwards compatibility changes. It is made sure that there is
a so-called *backwards compatibility layer* (or BC layer). This means that the
old API will still work, while the new feature is used internally. This BC
layer is then marked as *deprecated*, indicating that it will be
removed/changed in the future.
Copy link
Member

Choose a reason for hiding this comment

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

I think this is more technical than we need to be. The important thing is that your old code still works, but is deprecated. Perhaps (starting right after "compatibility changes.")

To accomplish this, the "old" (e.g. functions, classes, etc) code still works, but is marked
as *deprecated*, indicating that it will be removed/changed in the future and that you
should stop using it.


The major version is the only time all existing BC layers are removed. However,
if you make sure you've fixed all deprecated usages in the last version of the
previous major version, you should be able to upgrade to the new major version
without problems. To help you with this, the last minor releases will trigger
deprecated notices. For example, 2.7 and 2.8 trigger deprecated notices and if
you do not have any notice while using 2.8, you can savely upgrade to 3.0.
Copy link
Member

Choose a reason for hiding this comment

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

A slightly different suggestion, please mix and match - this stuff is just very important (which is why I'm so glad you wrote all this):

When the major version is released (e.g. 3.0.0), all deprecated features and functionality
are removed. So, as long as you've updated your code to stop using these deprecated
features in the last version before the major (e.g. 2.8.*), you should be able to upgrade
without a problem.

To help with this, the last minor releases will trigger deprecation notices. For example, Symfony
2.7 and 2.8 trigger deprecated notices that you can see in the web debug toolbar. When visiting
your application...


When visiting your application in the
:doc:`dev environment </cookbook/configuration/environments>` in your browser,
these notices are shown in the web dev toolbar:

.. image:: /images/cookbook/deprecations-in-profiler.png

Deprecations in PHPUnit
~~~~~~~~~~~~~~~~~~~~~~~

By default, PHPUnit will handle deprecation notices as real errors. This means
that all tests are aborted because it uses a BC layer.

To make sure this doesn't happen, you can install the PHPUnit bridge:

.. code-block:: bash

$ composer require symfony/phpunit-bridge
Copy link
Member

Choose a reason for hiding this comment

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

Currently, this will not work as the PHPUnit bridge was not part of a stable release yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

it will once 2.7 is stable and will be used as current. And as it's in a couple of weeks, I don't think it's usefull to have @dev in here.


Now, your tests execute normally and a nice summary of the deprecation notices
is displayed at the end of the test report:

.. code-block:: text

$ phpunit
...

OK (10 tests, 20 assertions)

Remaining deprecation notices (6)

The "request" service is deprecated and will be removed in 3.0. Add a typehint for
Symfony\Component\HttpFoundation\Request to your controller parameters to retrieve the
request instead: 6x
3x in PageAdminTest::testPageShow from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin
2x in PageAdminTest::testPageList from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin
1x in PageAdminTest::testPageEdit from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin

.. _upgrade-major-symfony-composer:

2) Update to the New Major Version via Composer
-----------------------------------------------

If your code is deprecation free, you can update the Symfony library via
Composer by modifying your ``composer.json`` file:

.. code-block:: json

{
"...": "...",

"require": {
"symfony/symfony": "3.0.*",
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to recommend 3.0.* as the constraint or ~3.0 like we do for 2.x branches (e.g. ~2.6)

Copy link
Member Author

Choose a reason for hiding this comment

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

In the upgrading articles, we've used x.y.* (even for 2.x branches).

My Composer rule is always: Keep version ranges as big as possible when developing 3th party libraries and as small as possible for your projects.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @wouterj. The user should be aware when updating to a new minor version and not get this implicitly in their applications.

Copy link
Member

Choose a reason for hiding this comment

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

I just follow the standard edition which - for whatever reason - uses the x.y.* format. I think we should continue to do the following so that people who follow the guide have stuff that looks like the SE.

},
"...": "...",
}

Next, use Composer to download new versions of the libraries:

.. code-block:: bash

$ composer update symfony/symfony

.. include:: /cookbook/upgrade/_update_all_packages.rst.inc

.. _upgrade-major-symfony-after:

3) Update your Code to Work with the New Version
Copy link
Member

Choose a reason for hiding this comment

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

Your

Copy link
Member Author

Choose a reason for hiding this comment

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

According to wikipedia (and other sources), determiners are part of the closed class words:

Typical closed classes are prepositions (or postpositions), determiners, conjunctions, and pronouns.

Copy link
Member

Choose a reason for hiding this comment

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

That's interesting. I thought it wasn't because it's based on "you". But apparently, you are right.

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

There is a high chance that you're done now! However, the next major version
Copy link
Member

Choose a reason for hiding this comment

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

There is a good chance (high doesn't sound quite right)

*may* also contain new BC breaks as a BC layer is not always a possibility.
Make sure you read the ``UPGRADE-X.0.md`` (where X is the new major version)
included in the Symfony repository for any BC break that you need to be aware
of.
63 changes: 63 additions & 0 deletions cookbook/upgrade/minor_version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.. index::
single: Upgrading; Minor Version

Upgrading a Minor Version (e.g. 2.5.3 to 2.6.1)
===============================================

If you're upgrading a minor version (where the middle number changes), then
you should *not* encounter significant backwards compatibility changes. For
details, see the :doc:`Symfony backwards compatibility promise </contributing/code/bc>`.

However, some backwards-compatibility breaks *are* possible and you'll learn in
a second how to prepare for them.

There are two steps to upgrading a minor version:

#. :ref:`Update the Symfony library via Composer <upgrade-minor-symfony-composer>`;
#. :ref:`Update your code to work with the new version <upgrade-minor-symfony-code>`.

.. _`upgrade-minor-symfony-composer`:

1) Update the Symfony Library via Composer
------------------------------------------

First, you need to update Symfony by modifying your ``composer.json`` file
to use the new version:

.. code-block:: json

{
"...": "...",

"require": {
"symfony/symfony": "2.6.*",
},
"...": "...",
}

Next, use Composer to download new versions of the libraries:

.. code-block:: bash

$ composer update symfony/symfony

.. include:: /cookbook/upgrade/_update_all_packages.rst.inc

.. _`upgrade-minor-symfony-code`:

2) Updating your Code to Work with the new Version
--------------------------------------------------

In theory, you should be done! However, you *may* need to make a few changes
to your code to get everything working. Additionally, some features you're
using might still work, but might now be deprecated. While that's just fine,
if you know about these deprecations, you can start to fix them over time.

Every version of Symfony comes with an UPGRADE file included in the Symfony
Copy link
Member

Choose a reason for hiding this comment

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

UPGRADE file (e.g. UPGRADE-2.7.md)

maybe even make the UPGRDE-2.7.md a link to GitHub?

directory that describes these changes. If you follow the instructions in the
document and update your code accordingly, it should be save to update in the
Copy link
Member

Choose a reason for hiding this comment

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

should be safe...

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah, these are your own words 😉

future.

These documents can also be found in the `Symfony Repository`_.

.. _`Symfony Repository`: https://github.com/symfony/symfony
26 changes: 26 additions & 0 deletions cookbook/upgrade/patch_version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. index::
single: Upgrading; Patch Version

Upgrading a Patch Version (e.g. 2.6.0 to 2.6.1)
===============================================

When a new patch version is released (only the last number changed), it is a
release that only contains bug fixes. This means that upgrading to a new patch
version is *really* easy:

.. code-block:: bash

$ composer update symfony/symfony

That's it! You should not encounter any backwards-compatibility breaks or
need to change anything else in your code. That's because when you started
your project, your ``composer.json`` included Symfony using a constraint
like ``2.6.*``, where only the *last* version number will change when you
update.

.. tip::

It is recommended to update to a new patch version as soon as possible, as
important bugs and security leaks may be fixed in these new releases.

.. include:: /cookbook/upgrade/_update_all_packages.rst.inc
Loading