Skip to content
  • Benni Mack's avatar
    [!!!][TASK] Use native trigger_error and ErrorHandler for deprecations · 95b13dca
    Benni Mack authored and Christian Kuhn's avatar Christian Kuhn committed
    The native PHP way of triggering deprecations by a framework or
    applications is done via
    `trigger_error($deprecationMessage, E_USER_DEPRECATED)`.
    
    Previously, TYPO3 used `GeneralUtility::deprecationLog()` and
    similar methods to generate a custom deprecation log, however it's
    more flexible to use native logging through TYPO3's ErrorHandler.
    
    This solution centralizes the way to configure the place if and
    how deprecation logs should be written to various log destinations.
    
    This also changes the way how deprecated methods, arguments and classes
    are handled.
    
    The new way to deprecate code in TYPO3 is done via
    `trigger_error()`, the @deprecated annotation within a method only
    exists now for IDE support, but is not reflected anymore for the
    logging message.
    That's why the @deprecated annotation does not contain
    a description anymore.
    
    The methods
    GeneralUtility::logDeprecatedFunction()
    GeneralUtility::deprecationLog()
    GeneralUtility::getDeprecationLogFileName()
    GeneralUtility::logDeprecatedViewHelperAttribute()
    
    are marked as deprecated from now on.
    
    The configuration option $TYPO3_CONF_VARS[SYS][enableDeprecationLog]
    is removed.
    
    Deprecation messages can now be activated by adding
    the E_USER_DEPRECATED constant to the respective values in
    
    $TYPO3_CONF_VARS[SYS][errorHandlerErrors]
     (so exceptions are handled by the TYPO3 error handler)
    $TYPO3_CONF_VARS[SYS][syslogErrorReporting]
     (so exceptions are put into GeneralUtility::sysLog)
    $TYPO3_CONF_VARS[SYS][belogErrorReporting]
     (so exceptions are put into sys_log DB table)
    $TYPO3_CONF_VARS[SYS][exceptionalErrors]
     (so exceptions are thrown on a deprecation)
    
    Deprecations will still go into GeneralUtility::devLog(),
    if deprecations are activated via the "errorHandlerErrors" option.
    
    Tests which test explicitly for deprecated code is moved into
    Tests/UnitDeprecated, to ensure that the deprecated code is not
    throwing an exception.
    
    Resolves: #82438
    Releases: master
    Change-Id: I6ef9a642d179001f0484c4c7678e0bec12284faf
    Reviewed-on: https://review.typo3.org/54015
    
    
    Reviewed-by: default avatarSusanne Moog <susanne.moog@typo3.org>
    Tested-by: default avatarSusanne Moog <susanne.moog@typo3.org>
    Tested-by: default avatarTYPO3com <no-reply@typo3.com>
    Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
    Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
    95b13dca