diff --git a/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php b/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php index d56325a21fca3f7e21297a4891791584230ebc87..fc3c5c3d2f38075c3e13a7c6c75bbcd64e8d31ac 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 26064683df668d639ec27954d777160c7cc007d3..290a91d98e42c43ada898e70d92f0d2eb5e391e6 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 0000000000000000000000000000000000000000..a0282213ff2fb5dd41085b39dcb36b72b9d903eb --- /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 dc07afc096f5eb741f2ee566e3a7ab490c9f53a2..6024e18c5a734b6fa0ec4d4dcaa2e0b286dedbf3 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', + ], + ], ];