-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Adding a new entry about deprecation warnings #5329
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
What do these "XXX is deprecated " E_USER_DEPRECATED Warnings mean? | ||
=================================================================== | ||
|
||
Starting in Symfony 2.7, if you use a deprecated class, function or option, | ||
Symfony triggers an ``E_USER_DEPRECATED`` error. Internally, that looks something | ||
like this:: | ||
|
||
trigger_error( | ||
'The fooABC method is deprecated since version 2.4 and will be removed in 3.0.', | ||
E_USER_DEPRECATED | ||
); | ||
|
||
This is great, because you can check your logs to know what needs to change | ||
before you upgrade. In the Symfony Framework, the number of deprecated calls | ||
shows up in the web debug toolbar. And if you install the `phpunit-bridge`_, | ||
you can get a report of deprecated calls after running your tests. | ||
|
||
How can I Silence the Warnings? | ||
------------------------------- | ||
|
||
As useful as these are, you don't want them to show up while developing and | ||
you may also want to silence them on production to avoid filling up your | ||
error logs. | ||
|
||
In the Symfony Framework | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
In the Symfony Framework, ``~E_USER_DEPRECATED`` is added to ``app/bootstrap.php.cache`` | ||
automatically, but you need at least version 2.3.14 or 3.0.21 of the | ||
`SensioDistributionBundle`_. So, you may need to upgrade: | ||
|
||
.. code-block:: bash | ||
|
||
$ composer update sensio/distribution-bundle | ||
|
||
Once you've updated, the ``bootstrap.php.cache`` file is rebuilt automatically. | ||
At the top, you should see a line adding ``~E_USER_DEPRECATED``. | ||
|
||
Outside of the Symfony Framework | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
To do that, add ``~E_USER_DEPRECATED`` to your ``error_reporting`` | ||
setting in ``php.ini``: | ||
|
||
.. code-block:: ini | ||
|
||
; before | ||
error_reporting = E_ALL | ||
; after | ||
error_reporting = E_ALL & ~E_USER_DEPRECATED | ||
|
||
Alternatively, you can set this directly in bootstrap of your project:: | ||
|
||
error_reporting(error_reporting() & ~E_USER_DEPRECATED); | ||
|
||
How can I Fix the Warnings? | ||
--------------------------- | ||
|
||
Of course ultimately, you want to stop using the deprecated functionality. | ||
Sometimes, this is easy: the warning might tell you exactly what to change. | ||
|
||
But other times, the warning might be unclear: a setting somewhere might | ||
cause a class deeper to trigger the warning. In this case, Symfony does its | ||
best to give a clear message, but you may need to research that warning further. | ||
|
||
And sometimes, the warning may come from a third-party library or bundle | ||
that you're using. If that's true, there's a good chance that those deprecations | ||
have already been updated. In that case, upgrade the library to fix them. | ||
|
||
Once all the deprecation warnings are gone, you can upgrade with a lot | ||
more confidence. | ||
|
||
.. _`phpunit-bridge`: https://github.com/symfony/phpunit-bridge | ||
.. _`SensioDistributionBundle`: https://github.com/sensiolabs/SensioDistributionBundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we should tell them exactly in which file and which line they should put this instruction. Moreover, maybe we should also mention that calling this function will slow down the application and it's much better to just change the setting in
php.ini
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 agree with telling a specific file, but in the framework, this is taken care of for you automatically (actually, I need to add a note about that - similar to https://github.com/symfony/symfony/pull/14776/files#diff-722b43ae068b297ed9d04d3b08ec16cfR14.
And of course, outside of the framework, we don't know what files they'll have. Any other suggestion? And I'm not sure about the performance hit of calling this one function. After all, we are actually doing this in the framework.