Skip to content

Commit a807b7e

Browse files
sbuerkohader
authored andcommitted
[TASK] Mitigate PHP 8.4.0-RC1 breaking changes
Note that this change addresses three different issues, which need to be done in one step, otherwise none of isolated patches would get a +1 CI verification: * Alignment for changed `$escape` parameter handling of CSV related methods, which must be avoided with PHP versions below 8.4.0-beta5, but is required as of PHP 8.4.0-RC1. * This `$escape` issue needs to be addressed directly in the `typo3/testing-framework` and thus needs a raised dependency directly. * PHP 8.4.0.0-RC1 also deprecated the `E_STRICT` constant, which needs to be addressed directly. With [1] the `$escape` parameter for the following method calls * `str_getcsv()` * `fputcsv()` * `fgetcsv()` must be provided as a 1 character long value. Omitting and using the default value will emit a PHP deprecation [2] warning as of PHP 8.4.0-RC1, for example: str_getcsv(): the $escape parameter must be provided as its default value will change To mitigate this, PHP recommends following: It must be passed explicitly either positionally or via named arguments. This change adjusts all occurences (function calls) and ensures that the `$escape` parameter is explicitly provided via specifying all parameters up to that position and not using a `named arguments` approach for easier backporting. The TYPO3 testing framework also needs to be aligned to mitigate `fgetcsv()` issues, and is raised in the same step - otherwise none of these changes would get a green CI pipeline run. The following testing-framework updates are adjusted: * main: simple update `main` pointer * 12.4: Raise to tag `8.2.2` * 11.5: Raise to tag `6.16.10` Used command(s): > composer update "typo3/testing-framework" Note that the backport has been squashed with the later partly revert using integer values instead of adding a own deprecated constant #105165 for [3][4]. We can not deprecate a constant and use it at the same time. We basically traded a deprecated constant with a new deprecated constant. Therefore this intermediate constant (added without being released yet in #105155) is removed again and replaced by a plain value. It's too likely that this constant is used by 3rd party code (or dependencies like typo3/testing-framework), which then makes it hard to remove this constant again (despite being deprecated). Also defining an own constant – that looks like an official PHP constant – into the global space, has caused immediate confusions which we want to avoid by using a scalar value + comment. The reason (possible 3rd party extensions that may still trigger this error) why this is kept (and not just removed) is also added to all usages now. [1] php/php-src#15569 [2] https://github.com/php/php-src/blob/ebee8df27ed/UPGRADING#L617-L622 [3] https://github.com/php/php-src/blob/ebee8df27edf7/UPGRADING#L47-L49 [4] php/php-src#13053 Resolves: #105155 Resolves: #105165 Releases: main, 13.3, 12.4, 11.5 Change-Id: Ie8b7d46eeb75ba6e32c0e8f6e7e947775083cc15 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86456 Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Oliver Hader <oliver.hader@typo3.org> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Oliver Hader <oliver.hader@typo3.org> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
1 parent 6b9220e commit a807b7e

File tree

13 files changed

+40
-22
lines changed

13 files changed

+40
-22
lines changed

composer.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typo3/sysext/backend/Classes/Form/Wizard/SuggestWizardDefaultReceiver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ protected function buildConstraintBlock(string $searchString)
266266
*/
267267
protected function splitSearchString(string $searchString): array
268268
{
269-
return str_getcsv($searchString, ' ');
269+
return str_getcsv($searchString, ' ', '"', '\\');
270270
}
271271

272272
/**

typo3/sysext/core/Classes/Error/ErrorHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ class ErrorHandler implements ErrorHandlerInterface, LoggerAwareInterface
6262
E_USER_ERROR => 'PHP User Error',
6363
E_USER_WARNING => 'PHP User Warning',
6464
E_USER_NOTICE => 'PHP User Notice',
65-
E_STRICT => 'PHP Runtime Notice',
6665
E_RECOVERABLE_ERROR => 'PHP Catchable Fatal Error',
6766
E_USER_DEPRECATED => 'TYPO3 Deprecation Notice',
6867
E_DEPRECATED => 'PHP Runtime Deprecation Notice',
68+
// @todo: Remove 2048 (deprecated E_STRICT) in v14, as this value is no longer used by PHP itself
69+
// and only kept here here because possible custom PHP extensions may still use it.
70+
// See https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant
71+
2048 /* deprecated E_STRICT */ => 'PHP Runtime Notice',
6972
];
7073

7174
/**

typo3/sysext/core/Classes/LinkHandling/TypoLinkCodecService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function decode(string $typoLink): array
9494
{
9595
$typoLink = trim($typoLink);
9696
if ($typoLink !== '') {
97-
$parts = str_replace(['\\\\', '\\"'], ['\\', '"'], str_getcsv($typoLink, self::DELIMITER));
97+
$parts = str_replace(['\\\\', '\\"'], ['\\', '"'], str_getcsv($typoLink, self::DELIMITER, '"', '\\'));
9898
} else {
9999
$parts = [];
100100
}

typo3/sysext/core/Classes/Resource/Index/FileIndexRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function findByFolders(array $folders, $includeMissing = true, $fileName
244244
);
245245

246246
if (isset($fileName)) {
247-
$nameParts = str_getcsv($fileName, ' ');
247+
$nameParts = str_getcsv($fileName, ' ', '"', '\\');
248248
foreach ($nameParts as $part) {
249249
$part = trim($part);
250250
if ($part !== '') {

typo3/sysext/core/Classes/Resource/Search/QueryRestrictions/SearchTermRestriction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private function makeQuerySearchByTable(string $tableName, string $tableAlias):
6969
$searchTerm = (string)$this->searchDemand->getSearchTerm();
7070
$constraints = [];
7171

72-
$searchTermParts = str_getcsv($searchTerm, ' ');
72+
$searchTermParts = str_getcsv($searchTerm, ' ', '"', '\\');
7373
foreach ($searchTermParts as $searchTermPart) {
7474
$searchTermPart = trim($searchTermPart);
7575
if ($searchTermPart === '') {

typo3/sysext/core/Classes/Utility/ArrayUtility.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static function getValueByPath(array $array, array|string $path, string $
181181
// Programming error has to be sanitized before calling the method -> global exception
182182
throw new \RuntimeException('Path must not be empty', 1341397767);
183183
}
184-
$path = str_getcsv($path, $delimiter);
184+
$path = str_getcsv($path, $delimiter, '"', '\\');
185185
}
186186
// Loop through each part and extract its value
187187
$value = $array;
@@ -265,7 +265,7 @@ public static function setValueByPath(array $array, string|array|\ArrayAccess $p
265265
throw new \RuntimeException('Path must not be empty', 1341406194);
266266
}
267267
// Extract parts of the path
268-
$path = str_getcsv($path, $delimiter);
268+
$path = str_getcsv($path, $delimiter, '"', '\\');
269269
}
270270
// Point to the root of the array
271271
$pointer = &$array;
@@ -306,7 +306,7 @@ public static function removeByPath(array $array, string $path, string $delimite
306306
throw new \RuntimeException('Path must not be empty', 1371757718);
307307
}
308308
// Extract parts of the path
309-
$pathSegments = str_getcsv($path, $delimiter);
309+
$pathSegments = str_getcsv($path, $delimiter, '"', '\\');
310310
$pathDepth = count($pathSegments);
311311
$currentDepth = 0;
312312
$pointer = &$array;

typo3/sysext/core/Classes/Utility/CsvUtility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function csvToArray(string $input, string $fieldDelimiter = ',', s
5858
if (($handle = fopen('php://memory', 'r+')) !== false) {
5959
fwrite($handle, $input);
6060
rewind($handle);
61-
while (($cells = fgetcsv($handle, 0, $fieldDelimiter, $fieldEnclosure)) !== false) {
61+
while (($cells = fgetcsv($handle, 0, $fieldDelimiter, $fieldEnclosure, '\\')) !== false) {
6262
$maximumCellCount = max(count($cells), $maximumCellCount);
6363
$multiArray[] = preg_replace('|<br */?>|i', LF, $cells);
6464
}
@@ -110,7 +110,7 @@ public static function csvValues(array $row, string $delim = ',', string $quote
110110
} elseif ($type === self::TYPE_PREFIX_CONTROLS) {
111111
$row = array_map(self::prefixControlLiterals(...), $row);
112112
}
113-
fputcsv($resource, $modifier($row), $delim, $quote);
113+
fputcsv($resource, $modifier($row), $delim, $quote, '\\');
114114
fseek($resource, 0);
115115
return stream_get_contents($resource);
116116
}

typo3/sysext/core/Configuration/DefaultConfiguration.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,12 @@
260260
'productionExceptionHandler' => \TYPO3\CMS\Core\Error\ProductionExceptionHandler::class,
261261
'debugExceptionHandler' => \TYPO3\CMS\Core\Error\DebugExceptionHandler::class,
262262
'errorHandler' => \TYPO3\CMS\Core\Error\ErrorHandler::class,
263-
'errorHandlerErrors' => E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR),
264-
'exceptionalErrors' => E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR | E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_WARNING),
265-
'belogErrorReporting' => E_ALL & ~(E_STRICT | E_NOTICE),
263+
// @todo: Remove 2048 (deprecated E_STRICT) in v14, as this value is no longer used by PHP itself
264+
// and only kept here here because possible custom PHP extensions may still use it.
265+
// See https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant
266+
'errorHandlerErrors' => E_ALL & ~(2048 /* deprecated E_STRICT */ | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR),
267+
'exceptionalErrors' => E_ALL & ~(2048 /* deprecated E_STRICT */ | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR | E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_WARNING),
268+
'belogErrorReporting' => E_ALL & ~(2048 /* deprecated E_STRICT */ | E_NOTICE),
266269
'allowedPhpDisableFunctions' => [],
267270
'locallangXMLOverride' => [], // For extension/overriding of the arrays in 'locallang' files in frontend and backend.
268271
'generateApacheHtaccess' => 1,

typo3/sysext/core/Tests/Functional/Error/ErrorHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ public function handleErrorOnlyHandlesRegisteredErrorLevels(): void
8888
$logger->expects(self::never())->method('log');
8989

9090
$coreErrorHandler = new ErrorHandler(
91-
E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR)
91+
// @todo: Remove 2048 (deprecated E_STRICT) in v14, as this value is no longer used by PHP itself
92+
// and only kept here here because possible custom PHP extensions may still use it.
93+
// See https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant
94+
E_ALL & ~(2048 /* deprecated E_STRICT */ | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR)
9295
);
9396
$coreErrorHandler->setLogger($logger);
9497

typo3/sysext/core/Tests/Unit/Error/ErrorHandlerTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ final class ErrorHandlerTest extends UnitTestCase
4141
protected LoggerInterface $trackingLogger;
4242

4343
// These are borrowed from DefaultConfiguration.php.
44-
protected const DEFAULT_ERROR_HANDLER_LEVELS = E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR);
45-
protected const DEFAULT_EXCEPTIONAL_ERROR_LEVELS = E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR | E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_WARNING);
44+
// @todo: Remove 2048 (deprecated E_STRICT) in v14, as this value is no longer used by PHP itself
45+
// and only kept here here because possible custom PHP extensions may still use it.
46+
// See https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant
47+
protected const DEFAULT_ERROR_HANDLER_LEVELS = E_ALL & ~(2048 /* deprecated E_STRICT */ | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR);
48+
protected const DEFAULT_EXCEPTIONAL_ERROR_LEVELS = E_ALL & ~(2048 /* deprecated E_STRICT */ | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR | E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_WARNING);
4649

4750
protected bool $resetSingletonInstances = true;
4851

typo3/sysext/core/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
"TYPO3\\CMS\\Core\\": "Classes/"
119119
},
120120
"classmap": ["Resources/PHP/"],
121-
"files": ["Resources/PHP/GlobalDebugFunctions.php"]
121+
"files": [
122+
"Resources/PHP/GlobalDebugFunctions.php"
123+
]
122124
}
123125
}

typo3/sysext/install/Classes/ViewHelpers/Format/PhpErrorCodeViewHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ final class PhpErrorCodeViewHelper extends AbstractViewHelper
3838
E_USER_ERROR => 'E_USER_ERROR',
3939
E_USER_WARNING => 'E_USER_WARNING',
4040
E_USER_NOTICE => 'E_USER_NOTICE',
41-
E_STRICT => 'E_STRICT',
4241
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
4342
E_DEPRECATED => 'E_DEPRECATED',
4443
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
44+
// @todo: Remove 2048 (deprecated E_STRICT) in v14, as this value is no longer used by PHP itself
45+
// and only kept here here because possible custom PHP extensions may still use it.
46+
// See https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant
47+
2048 /* deprecated E_STRICT */ => 'PHP Runtime Notice',
4548
];
4649

4750
public function initializeArguments(): void

0 commit comments

Comments
 (0)