Task #70584
closedReduce thrown E_NOTICEs
0%
Description
Every time PHP tries to access an index of an array, which is not set, or a variable that is not defined PHP generated an E_NOTICE and uses NULL as resulting value.
This is bad because of three major reasons:
1. Bugs resulting from an invalid evaluation of the value are very hard to find.
2. You can not trust the type of the variable so you have to check it anywhere you use it.
3. Not checking keys is considered bad code.
And a lot of other (major and minor) reasons to check the key/variable before accessing it, including tiny performance improvements as a positive side effect.
Mission:¶
Always check if the variable/key exists before accessing it.
If the value is not existent use the expected default value (e.g.: empty string, zero, null..)
How to work on this:¶
Edit UnitTests.xml in core/Build and set convertNoticesToExceptions="true"
and stopOnFailure="true"
as <phpunit> tag attributes.
Go to \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::initializeBasicErrorReporting and set error_reporting(E_ALL)
Run all unit tests. PHPUnit will halt on the first error.
Create a child issue on this ticket that combines some changes into logic units.
There shouldn't be more than 20 changes per patch to keep them simple and increase velocity. Smaller patches are getting approved and merged faster.
Updated by Riccardo De Contardi over 7 years ago
- Target version changed from 8 LTS to Candidate for Major Version
Updated by Gerrit Code Review almost 7 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54884
Updated by Gerrit Code Review almost 7 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54884
Updated by Gerrit Code Review almost 7 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54884
Updated by Riccardo De Contardi over 6 years ago
- Related to Bug #84156: avoid E_NOTICE reporting in ArrayUtility added
Updated by Ralf Zimmermann over 6 years ago
- Related to Bug #84161: avoid E_NOTICE reporting in ArrayUtility - reloaded added
Updated by Gerrit Code Review over 6 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54884
Updated by Gerrit Code Review over 6 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54884
Updated by Łukasz Uznański over 6 years ago
- Sprint Focus set to On Location Sprint
Updated by Christian Kuhn over 6 years ago
- Related to Epic #84280: Make unit tests notice free added
Updated by Gerrit Code Review over 6 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54884
Updated by Jan Helke over 6 years ago
- Status changed from Under Review to Resolved
- Assignee deleted (
Oliver Eglseder)
All issues connected to this task are either closed or resolved. I will close the ticket and we will handle E_NOTICEs further on in https://forge.typo3.org/issues/84280