Skip to content

Commit e74bbc9

Browse files
committed
Adding a new entry about deprecation warnings
1 parent 8b0c026 commit e74bbc9

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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. To do that, add ``~E_USER_DEPRECATED`` to your ``error_reporting``
24+
setting in ``php.ini``:
25+
26+
.. code-block:: ini
27+
28+
; before
29+
error_reporting = E_ALL
30+
; after
31+
error_reporting = E_ALL & ~E_USER_DEPRECATED
32+
33+
Alternatively, you can set this directly in bootstrap of your project::
34+
35+
error_reporting(error_reporting() & ~E_USER_DEPRECATED);
36+
37+
How can I Fix the Warnings?
38+
---------------------------
39+
40+
Of course ultimately, you want to stop using the deprecated functionality.
41+
Sometimes, this is easy: the warning might tell you exactly what to change.
42+
43+
But other times, the warning might be un-clear: a setting somewhere might
44+
cause a class deeper to trigger the warning. In this case, the core team
45+
does its best to give a clear message, but you may need to research that
46+
warning further.
47+
48+
And sometimes, the warning may come from a third-party library or bundle
49+
that you're using. If that's true, there's a good chance that those deprecations
50+
have already been updated. In that case, upgrade the library to fix them.
51+
52+
Once all the deprecation warnings are gone, you can upgrade without a lot
53+
more confidence.
54+
55+
.. _`phpunit-bridge`: https://github.com/symfony/phpunit-bridge
56+

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy