Skip to content

Commit 7901078

Browse files
committed
[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 require --dev "typo3/testing-framework":"^6.16.10" Additionally, PHP 8.4.0-RC1 deprecated the `E_STRICT` constant, which now emits a E_DEPRECATED which leads to failed CI tests. This change introduces a core internal constant with the same integer value, and replaces usages with this constant to mitigate the E_DEPRECATION. This constant can then be dropped with TYPO3 v14, preventing a breaking change at this time. [3][4] [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 Releases: main, 12.4, 11.5 Change-Id: Ie8b7d46eeb75ba6e32c0e8f6e7e947775083cc15 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/86377 Tested-by: Stefan Bürk <[email protected]> Reviewed-by: Garvin Hicking <[email protected]> Tested-by: core-ci <[email protected]> Reviewed-by: Stefan Bürk <[email protected]> Tested-by: Garvin Hicking <[email protected]>
1 parent d96e80c commit 7901078

File tree

10 files changed

+46
-12
lines changed

10 files changed

+46
-12
lines changed

Classes/Error/ErrorHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ class ErrorHandler implements ErrorHandlerInterface, LoggerAwareInterface
6161
E_USER_ERROR => 'PHP User Error',
6262
E_USER_WARNING => 'PHP User Warning',
6363
E_USER_NOTICE => 'PHP User Notice',
64-
E_STRICT => 'PHP Runtime Notice',
6564
E_RECOVERABLE_ERROR => 'PHP Catchable Fatal Error',
6665
E_USER_DEPRECATED => 'TYPO3 Deprecation Notice',
6766
E_DEPRECATED => 'PHP Runtime Deprecation Notice',
67+
// @todo Remove intermediate constant E_STRICT_DEPRECATED with TYPO3 v14. E_STRICT (2048) constant deprecated since PHP 8.4.0 RC1.
68+
E_STRICT_DEPRECATED => 'PHP Runtime Notice',
6869
];
6970

7071
/**

Classes/Resource/Index/FileIndexRepository.php

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

261261
if (isset($fileName)) {
262-
$nameParts = str_getcsv($fileName, ' ');
262+
$nameParts = str_getcsv($fileName, ' ', '"', '\\');
263263
foreach ($nameParts as $part) {
264264
$part = trim($part);
265265
if ($part !== '') {

Classes/Resource/Search/QueryRestrictions/SearchTermRestriction.php

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

75-
$searchTermParts = str_getcsv($searchTerm, ' ');
75+
$searchTermParts = str_getcsv($searchTerm, ' ', '"', '\\');
7676
foreach ($searchTermParts as $searchTermPart) {
7777
$searchTermPart = trim($searchTermPart);
7878
if ($searchTermPart === '') {

Classes/Utility/ArrayUtility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static function getValueByPath(array $array, $path, $delimiter = '/')
185185
// Programming error has to be sanitized before calling the method -> global exception
186186
throw new \RuntimeException('Path must not be empty', 1341397767);
187187
}
188-
$path = str_getcsv($path, $delimiter);
188+
$path = str_getcsv($path, $delimiter, '"', '\\');
189189
} elseif (!is_array($path)) {
190190
// Programming error has to be sanitized before calling the method -> global exception
191191
throw new \InvalidArgumentException('getValueByPath() expects $path to be string or array, "' . gettype($path) . '" given.', 1476557628);

Classes/Utility/CsvUtility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function csvToArray($input, $fieldDelimiter = ',', $fieldEnclosure
5757
if (($handle = fopen('php://memory', 'r+')) !== false) {
5858
fwrite($handle, $input);
5959
rewind($handle);
60-
while (($cells = fgetcsv($handle, 0, $fieldDelimiter, $fieldEnclosure)) !== false) {
60+
while (($cells = fgetcsv($handle, 0, $fieldDelimiter, $fieldEnclosure, '\\')) !== false) {
6161
$cells = is_array($cells) ? $cells : [];
6262
$maximumCellCount = max(count($cells), $maximumCellCount);
6363
$multiArray[] = preg_replace('|<br */?>|i', LF, $cells);

Configuration/DefaultConfiguration.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,13 @@
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 intermediate constant E_STRICT_DEPRECATED with TYPO3 v14. E_STRICT (2048) constant deprecated since PHP 8.4.0 RC1.
264+
'errorHandlerErrors' => E_ALL & ~(E_STRICT_DEPRECATED | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR),
265+
// @todo Remove intermediate constant E_STRICT_DEPRECATED with TYPO3 v14. E_STRICT (2048) constant deprecated since PHP 8.4.0 RC1.
266+
'exceptionalErrors' => E_ALL & ~(E_STRICT_DEPRECATED | 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),
267+
// @todo Remove intermediate constant E_STRICT_DEPRECATED with TYPO3 v14. E_STRICT (2048) constant deprecated since PHP 8.4.0 RC1.
268+
'belogErrorReporting' => E_ALL & ~(E_STRICT_DEPRECATED | E_NOTICE),
269+
'allowedPhpDisableFunctions' => [],
266270
'locallangXMLOverride' => [], // For extension/overriding of the arrays in 'locallang' files in frontend and backend.
267271
'generateApacheHtaccess' => 1,
268272
'ipAnonymization' => 1,

Resources/PHP/DeprecatedConstants.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the TYPO3 CMS project.
5+
*
6+
* It is free software; you can redistribute it and/or modify it under
7+
* the terms of the GNU General Public License, either version 2
8+
* of the License, or any later version.
9+
*
10+
* For the full copyright and license information, please read the
11+
* LICENSE.txt file that was distributed with this source code.
12+
*
13+
* The TYPO3 project - inspiring people to share!
14+
*/
15+
16+
/**
17+
* @internal only for TYPO3 internal work and not part of public API. Remove usage in custom extension code to mitigate
18+
* PHP deprecated constant E_STRICT.
19+
* @deprecated since v13, will be removed in v14. This constant is only for TYPO3 internal usage to replace the
20+
* deprecated `E_STRICT` constant of PHP since PHP 8.4.0 RC1 to avoid E_DEPRECATED messages within
21+
* automatic testing.
22+
*/
23+
define('E_STRICT_DEPRECATED', 2048);

Tests/Functional/Error/ErrorHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public function handleErrorOnlyHandlesRegisteredErrorLevels(): void
9393
$logger->expects(self::never())->method('log');
9494

9595
$coreErrorHandler = new ErrorHandler(
96-
E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR)
96+
// @todo Remove intermediate constant E_STRICT_DEPRECATED with TYPO3 v14. E_STRICT (2048) constant deprecated since PHP 8.4.0 RC1.
97+
E_ALL & ~(E_STRICT_DEPRECATED | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR)
9798
);
9899
$coreErrorHandler->setLogger($logger);
99100

Tests/Unit/Error/ErrorHandlerTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ class ErrorHandlerTest extends UnitTestCase
3838
protected LoggerInterface $trackingLogger;
3939

4040
// These are borrowed from DefaultConfiguration.php.
41-
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);
42-
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);
41+
// @todo Remove intermediate constant E_STRICT_DEPRECATED with TYPO3 v14. E_STRICT (2048) constant deprecated since PHP 8.4.0 RC1.
42+
protected const DEFAULT_ERROR_HANDLER_LEVELS = E_ALL & ~(E_STRICT_DEPRECATED | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR);
43+
// @todo Remove intermediate constant E_STRICT_DEPRECATED with TYPO3 v14. E_STRICT (2048) constant deprecated since PHP 8.4.0 RC1.
44+
protected const DEFAULT_EXCEPTIONAL_ERROR_LEVELS = E_ALL & ~(E_STRICT_DEPRECATED | 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);
4345

4446
protected $resetSingletonInstances = true;
4547

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
"TYPO3\\CMS\\Core\\": "Classes/"
120120
},
121121
"classmap": ["Resources/PHP/"],
122-
"files": ["Resources/PHP/GlobalDebugFunctions.php"]
122+
"files": [
123+
"Resources/PHP/DeprecatedConstants.php",
124+
"Resources/PHP/GlobalDebugFunctions.php"
125+
]
123126
}
124127
}

0 commit comments

Comments
 (0)