Commit db92cbd1 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[!!!][TASK] Remove third parameter from ArrayUtility::arrayDiffAssocRecursive()

With #94137, the ArrayUtility::arrayDiffAssocRecursive
method was adjusted to actually behave like `array_diff_assoc`.

To not introduce a breaking change after 11.0, a third
parameter was added to enable the correct behaviour.

This parameter is now removed, the method does
now always behave correct.

Resolves: #96194
Related: #94137
Releases: main
Change-Id: Ic77dcccf738efa630936801885b11c51933ddbda
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72454


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 2dee6aed
......@@ -61,7 +61,7 @@ class Comparator extends \Doctrine\DBAL\Schema\Comparator
public function diffTable(Table $fromTable, Table $toTable)
{
$newTableOptions = array_merge($fromTable->getOptions(), $toTable->getOptions());
$optionDiff = ArrayUtility::arrayDiffAssocRecursive($newTableOptions, $fromTable->getOptions(), true);
$optionDiff = ArrayUtility::arrayDiffAssocRecursive($newTableOptions, $fromTable->getOptions());
$tableDifferences = parent::diffTable($fromTable, $toTable);
// No changed table options, return parent result
......
......@@ -789,30 +789,17 @@ class ArrayUtility
*
* @param array $array1 Source array
* @param array $array2 Reduce source array by this array
* @param bool $useArrayDiffAssocBehavior If false, the old array_diff_key() behavior is kept and a deprecation warning is triggered. Will be removed in TYPO3 v12.
* @return array Source array reduced by values also present in second array, indexed by key
*/
public static function arrayDiffAssocRecursive(array $array1, array $array2, bool $useArrayDiffAssocBehavior = false): array
public static function arrayDiffAssocRecursive(array $array1, array $array2): array
{
if (!$useArrayDiffAssocBehavior) {
trigger_error(
sprintf(
'Using the array_diff_key() behavior of %1$s is deprecated, use ArrayUtility::arrayDiffKeyRecursive() instead.'
. ' Set the 3rd parameter of %1$s to true to switch to array_diff_assoc(), which will become the default behavior in TYPO3 v12.',
__METHOD__
),
E_USER_DEPRECATED
);
return self::arrayDiffKeyRecursive($array1, $array2);
}
$differenceArray = [];
foreach ($array1 as $key => $value) {
if (!array_key_exists($key, $array2) || (!is_array($value) && $value !== $array2[$key])) {
$differenceArray[$key] = $value;
} elseif (is_array($value)) {
if (is_array($array2[$key])) {
$recursiveResult = self::arrayDiffAssocRecursive($value, $array2[$key], $useArrayDiffAssocBehavior);
$recursiveResult = self::arrayDiffAssocRecursive($value, $array2[$key]);
if (!empty($recursiveResult)) {
$differenceArray[$key] = $recursiveResult;
}
......
......@@ -95,12 +95,16 @@ The following PHP static class methods that have previously been marked as depre
- :php:`\TYPO3\CMS\T3editor\Registry\AddonRegistry::getInstance()`
- :php:`\TYPO3\CMS\T3editor\Registry\ModeRegistry::getInstance()`
The following methods changed signature according to previous deprecations in v11 at the end of the argument list:
The following PHP class methods changed signature according to previous deprecations in v11 at the end of the argument list:
- :php:`\TYPO3\CMS\Core\Core\ApplicationInterface->run` (argument 1 is removed)
- :php:`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->ATagParams` (argument 2 is removed)
The following methods changed signature according to previous deprecations in v11 and are now type hinted:
The following PHP static class methods changed signature according to previous deprecations in v11 at the end of the argument list:
- :php:`\TYPO3\CMS\Core\Utility\ArrayUtility::arrayDiffAssocRecursive()` (argument 3 is removed)
The following PHP class methods changed signature according to previous deprecations in v11 and are now type hinted:
- :php:`\TYPO3\CMS\Backend\Tree\View\AbstractTreeView->getIcon()` (first argument is now type hinted `array`)
......
......@@ -2553,7 +2553,7 @@ class ArrayUtilityTest extends UnitTestCase
$expectedResult = [
'key2' => 'value2',
];
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2, true);
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
self::assertEquals($expectedResult, $actualResult);
}
......@@ -2591,7 +2591,7 @@ class ArrayUtilityTest extends UnitTestCase
],
],
];
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2, true);
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
self::assertEquals($expectedResult, $actualResult);
}
......@@ -2618,7 +2618,7 @@ class ArrayUtilityTest extends UnitTestCase
'key2' => 'value2',
'key3' => 'value3',
];
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2, true);
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
self::assertEquals($expectedResult, $actualResult);
}
......@@ -2644,7 +2644,7 @@ class ArrayUtilityTest extends UnitTestCase
'key3' => 'value3',
];
$expectedResult = [];
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2, true);
$actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
self::assertEquals($expectedResult, $actualResult);
}
......
......@@ -80,6 +80,7 @@ return [
'maximumNumberOfArguments' => 2,
'restFiles' => [
'Deprecation-94137-SwitchBehaviorOfArrayUtilityarrayDiffAssocRecursive.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
];
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment