Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit78bab15

Browse files
committed
Merge branch '2.8'
* 2.8: Fix thanks to Wouter Added a section about the framework Tweaks thanks to Mr@javiereguiluz Adding a new entry about deprecation warnings
2 parents68f51df +6311638 commit78bab15

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

‎cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
* :doc:`/cookbook/upgrade/patch_version`
225225
* :doc:`/cookbook/upgrade/minor_version`
226226
* :doc:`/cookbook/upgrade/major_version`
227+
* :doc:`/cookbook/upgrade/deprecation_warnings`
227228

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
What do these "XXX is deprecated " E_USER_DEPRECATED Warnings mean?
2+
===================================================================
3+
4+
Starting in Symfony 2.7, if you use a deprecated class, function or option,
5+
Symfony triggers an ``E_USER_DEPRECATED`` error. Internally, that looks something
6+
like this::
7+
8+
trigger_error(
9+
'The fooABC method is deprecated since version 2.4 and will be removed in 3.0.',
10+
E_USER_DEPRECATED
11+
);
12+
13+
This is great, because you can check your logs to know what needs to change
14+
before you upgrade. In the Symfony Framework, the number of deprecated calls
15+
shows up in the web debug toolbar. And if you install the `phpunit-bridge`_,
16+
you can get a report of deprecated calls after running your tests.
17+
18+
How can I Silence the Warnings?
19+
-------------------------------
20+
21+
As useful as these are, you don't want them to show up while developing and
22+
you may also want to silence them on production to avoid filling up your
23+
error logs.
24+
25+
In the Symfony Framework
26+
~~~~~~~~~~~~~~~~~~~~~~~~
27+
28+
In the Symfony Framework, ``~E_USER_DEPRECATED`` is added to ``app/bootstrap.php.cache``
29+
automatically, but you need at least version 2.3.14 or 3.0.21 of the
30+
`SensioDistributionBundle`_. So, you may need to upgrade:
31+
32+
..code-block::bash
33+
34+
$ composer update sensio/distribution-bundle
35+
36+
Once you've updated, the ``bootstrap.php.cache`` file is rebuilt automatically.
37+
At the top, you should see a line adding ``~E_USER_DEPRECATED``.
38+
39+
Outside of the Symfony Framework
40+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41+
42+
To do that, add ``~E_USER_DEPRECATED`` to your ``error_reporting``
43+
setting in ``php.ini``:
44+
45+
..code-block::ini
46+
47+
; before
48+
error_reporting = E_ALL
49+
; after
50+
error_reporting = E_ALL & ~E_USER_DEPRECATED
51+
52+
Alternatively, you can set this directly in bootstrap of your project::
53+
54+
error_reporting(error_reporting() & ~E_USER_DEPRECATED);
55+
56+
How can I Fix the Warnings?
57+
---------------------------
58+
59+
Of course ultimately, you want to stop using the deprecated functionality.
60+
Sometimes, this is easy: the warning might tell you exactly what to change.
61+
62+
But other times, the warning might be unclear: a setting somewhere might
63+
cause a class deeper to trigger the warning. In this case, Symfony does its
64+
best to give a clear message, but you may need to research that warning further.
65+
66+
And sometimes, the warning may come from a third-party library or bundle
67+
that you're using. If that's true, there's a good chance that those deprecations
68+
have already been updated. In that case, upgrade the library to fix them.
69+
70+
Once all the deprecation warnings are gone, you can upgrade with a lot
71+
more confidence.
72+
73+
.. _`phpunit-bridge`:https://github.com/symfony/phpunit-bridge
74+
.. _`SensioDistributionBundle`:https://github.com/sensiolabs/SensioDistributionBundle

‎cookbook/upgrade/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ There are three types of upgrades, all needing a little different preparation:
1616
/cookbook/upgrade/patch_version
1717
/cookbook/upgrade/minor_version
1818
/cookbook/upgrade/major_version
19+
/cookbook/upgrade/deprecation_warnings

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp