Breaking: #101133 - Icon->state changed type

See forge#101133

Description

The protected property \TYPO3\CMS\Core\Imaging\Icon->state holds now a native enum \TYPO3\CMS\Core\Imaging\IconState instead of an instance of \TYPO3\CMS\Core\Type\Icon\IconState.

Impact

Custom extensions calling \TYPO3\CMS\Core\Imaging\Icon->getState() will receive an enum now, which will most probably lead to PHP errors in the runtime.

Custom extensions calling \TYPO3\CMS\Core\Imaging\Icon->setState() with an instance of \TYPO3\CMS\Core\Type\Icon\IconState will receive a PHP TypeError.

Affected installations

Custom extensions calling \TYPO3\CMS\Core\Imaging\Icon->getState() or \TYPO3\CMS\Core\Imaging\Icon->setState().

Migration

Adapt your code to handle the native enum \TYPO3\CMS\Core\Imaging\IconState.

use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Type\Icon\IconState;
use TYPO3\CMS\Core\Utility\GeneralUtility;

// Before
$icon = GeneralUtility::makeInstance(Icon::class);
$icon->setState(IconState::cast(IconState::STATE_DEFAULT));
$state = $icon->getState();
$stateValue = (string)$state;

// After
$icon = GeneralUtility::makeInstance(Icon::class);
$icon->setState(IconState::STATE_DEFAULT);

$state = $icon->getState();
$stateValue = $state->value;
Copied!