From 2f0d42dc9282e6d25af6b06cc6f509d1673a77a5 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Wed, 30 May 2018 21:26:21 +0200 Subject: [PATCH] [TASK] Deprecate T3_ERR_SV_ constants The following constants related to the Services in TYPO3 have been moved into AbstractService as class constants, effectively moving them in the right context. - T3_ERR_SV_GENERAL - T3_ERR_SV_NOT_AVAIL - T3_ERR_SV_WRONG_SUBTYPE - T3_ERR_SV_NO_INPUT - T3_ERR_SV_FILE_NOT_FOUND - T3_ERR_SV_FILE_READ - T3_ERR_SV_FILE_WRITE - T3_ERR_SV_PROG_NOT_FOUND - T3_ERR_SV_PROG_FAILED The Extension scanner will detect usages of these constants. The constants will be removed in TYPO3 v10. Resolves: #85123 Releases: master Change-Id: I9df12e51deda77903aff83769d4f2a532b2676fb Reviewed-on: https://review.typo3.org/57095 Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> --- .../Classes/Core/SystemEnvironmentBuilder.php | 1 + .../core/Classes/Service/AbstractService.php | 44 ++++++++++++++---- ...ation-85123-ConstantsRelatedToServices.rst | 44 ++++++++++++++++++ .../ExtensionScanner/Php/ConstantMatcher.php | 45 +++++++++++++++++++ 4 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-85123-ConstantsRelatedToServices.rst diff --git a/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php b/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php index d56325a21fca..fc3c5c3d2f38 100644 --- a/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php +++ b/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php @@ -137,6 +137,7 @@ class SystemEnvironmentBuilder defined('TYPO3_OS') ?: define('TYPO3_OS', self::getTypo3Os()); // Service error constants + // @deprecated since TYPO3 v9.3, will be removed in TYPO3 v10.0, use the class constants in AbstractService instead. // General error - something went wrong define('T3_ERR_SV_GENERAL', -1); // During execution it showed that the service is not available and should be ignored. The service itself should call $this->setNonAvailable() diff --git a/typo3/sysext/core/Classes/Service/AbstractService.php b/typo3/sysext/core/Classes/Service/AbstractService.php index 26064683df66..290a91d98e42 100644 --- a/typo3/sysext/core/Classes/Service/AbstractService.php +++ b/typo3/sysext/core/Classes/Service/AbstractService.php @@ -28,6 +28,34 @@ abstract class AbstractService implements LoggerAwareInterface { use LoggerAwareTrait; + // General error - something went wrong + const ERROR_GENERAL = -1; + + // During execution it showed that the service is not available and + // should be ignored. The service itself should call $this->setNonAvailable() + const ERROR_SERVICE_NOT_AVAILABLE = -2; + + // Passed subtype is not possible with this service + const ERROR_WRONG_SUBTYPE = -3; + + // Passed subtype is not possible with this service + const ERROR_NO_INPUT = -4; + + // File not found which the service should process + const ERROR_FILE_NOT_FOUND = -20; + + // File not readable + const ERROR_FILE_NOT_READABLE = -21; + + // File not writable + // @todo: check writeable vs. writable + const ERROR_FILE_NOT_WRITEABLE = -22; + + // Passed subtype is not possible with this service + const ERROR_PROGRAM_NOT_FOUND = -40; + + // Passed subtype is not possible with this service + const ERROR_PROGRAM_FAILED = -41; /** * @var array service description array */ @@ -161,10 +189,10 @@ abstract class AbstractService implements LoggerAwareInterface /** * Puts an error on the error stack. Calling without parameter adds a general error. * - * @param int $errNum Error number (see T3_ERR_SV_* constants) + * @param int $errNum Error number (see class constants) * @param string $errMsg Error message */ - public function errorPush($errNum = T3_ERR_SV_GENERAL, $errMsg = 'Unspecified error occurred') + public function errorPush($errNum = self::ERROR_GENERAL, $errMsg = 'Unspecified error occurred') { $this->error[] = ['nr' => $errNum, 'msg' => $errMsg]; /** @var \TYPO3\CMS\Core\TimeTracker\TimeTracker $timeTracker */ @@ -263,7 +291,7 @@ abstract class AbstractService implements LoggerAwareInterface foreach ($progList as $prog) { if (!CommandUtility::checkCommand($prog)) { // Program not found - $this->errorPush(T3_ERR_SV_PROG_NOT_FOUND, 'External program not found: ' . $prog); + $this->errorPush(self::ERROR_PROGRAM_NOT_FOUND, 'External program not found: ' . $prog); $ret = false; } } @@ -296,10 +324,10 @@ abstract class AbstractService implements LoggerAwareInterface if (@is_readable($absFile)) { $checkResult = $absFile; } else { - $this->errorPush(T3_ERR_SV_FILE_READ, 'File is not readable: ' . $absFile); + $this->errorPush(self::ERROR_FILE_NOT_READABLE, 'File is not readable: ' . $absFile); } } else { - $this->errorPush(T3_ERR_SV_FILE_NOT_FOUND, 'File not found: ' . $absFile); + $this->errorPush(self::ERROR_FILE_NOT_FOUND, 'File not found: ' . $absFile); } return $checkResult; } @@ -317,7 +345,7 @@ abstract class AbstractService implements LoggerAwareInterface if ($this->checkInputFile($absFile)) { $out = file_get_contents($absFile); if ($out === false) { - $this->errorPush(T3_ERR_SV_FILE_READ, 'Can not read from file: ' . $absFile); + $this->errorPush(self::ERROR_FILE_NOT_READABLE, 'Can not read from file: ' . $absFile); } } return $out; @@ -340,7 +368,7 @@ abstract class AbstractService implements LoggerAwareInterface @fwrite($fd, $content); @fclose($fd); } else { - $this->errorPush(T3_ERR_SV_FILE_WRITE, 'Can not write to file: ' . $absFile); + $this->errorPush(self::ERROR_FILE_NOT_WRITEABLE, 'Can not write to file: ' . $absFile); $absFile = false; } } @@ -361,7 +389,7 @@ abstract class AbstractService implements LoggerAwareInterface $this->registerTempFile($absFile); } else { $ret = false; - $this->errorPush(T3_ERR_SV_FILE_WRITE, 'Can not create temp file.'); + $this->errorPush(self::ERROR_FILE_NOT_WRITEABLE, 'Can not create temp file.'); } return $ret; } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85123-ConstantsRelatedToServices.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85123-ConstantsRelatedToServices.rst new file mode 100644 index 000000000000..a0282213ff2f --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85123-ConstantsRelatedToServices.rst @@ -0,0 +1,44 @@ +.. include:: ../../Includes.txt + +=================================================== +Deprecation: #85123 - Constants related to Services +=================================================== + +See :issue:`85123` + +Description +=========== + +The following constants have been marked as deprecated, and will be removed in TYPO3 v10.0. + +- T3_ERR_SV_GENERAL +- T3_ERR_SV_NOT_AVAIL +- T3_ERR_SV_WRONG_SUBTYPE +- T3_ERR_SV_NO_INPUT +- T3_ERR_SV_FILE_NOT_FOUND +- T3_ERR_SV_FILE_READ +- T3_ERR_SV_FILE_WRITE +- T3_ERR_SV_PROG_NOT_FOUND +- T3_ERR_SV_PROG_FAILED + +The according constants have been moved to class constants of :php:`TYPO3\CMS\Core\Service\AbstractService`. + + +Impact +====== + +These constants will not trigger a deprecation warning, however they will result in a fatal error in TYPO3 v10.0. + + +Affected Installations +====================== + +TYPO3 Installations with extensions using these constants or having custom services using these constants. + + +Migration +========= + +Use the class constants provided within :php:`TYPO3\CMS\Core\Service\AbstractService`. + +.. index:: PHP-API, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ConstantMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ConstantMatcher.php index dc07afc096f5..6024e18c5a73 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ConstantMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ConstantMatcher.php @@ -20,4 +20,49 @@ return [ 'Breaking-82296-UserAgentConstantRemoved.rst', ], ], + 'T3_ERR_SV_GENERAL' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_NOT_AVAIL' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_WRONG_SUBTYPE' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_NO_INPUT' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_FILE_NOT_FOUND' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_FILE_READ' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_FILE_WRITE' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_PROG_NOT_FOUND' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], + 'T3_ERR_SV_PROG_FAILED' => [ + 'restFiles' => [ + 'Deprecation-85123-ConstantsRelatedToServices.rst', + ], + ], ]; -- GitLab