Deprecation: #111134 - #[Transient] for skipping validation
See forge#111134
Description
Since forge#91727, the Extbase attribute
\TYPO3\ also skips the validator that
Extbase generates automatically for properties typed as another model or as a
collection. This coupled validation to a persistence attribute.
Relying on
# to skip validation of such a property has been
marked as deprecated and will be removed in TYPO3 v16.0. The new attribute
\TYPO3\ can be used on properties
instead, see Feature: #111134 - Allow #[IgnoreValidation] on Extbase properties.
Impact
Extbase triggers a PHP deprecation warning when it builds the validators of a
model that has a property with
# and no
#, and Extbase would otherwise generate a validator
for that property. This applies to properties typed as another model and to
typed collections such as
Object. The validator is
still skipped until TYPO3 v16.0. Starting with TYPO3 v16.0,
#
does not influence validation anymore and the automatically generated validator
is applied.
Properties for which Extbase never generates a validator, for example properties of simple types or of singleton classes, are not affected and trigger no deprecation.
Properties typed as other classes, for example
\Date,
trigger the deprecation as well, although the validator generated for them is
empty. Adding
# to such a property silences the
deprecation and changes nothing else.
Affected installations
TYPO3 installations with extensions that have domain model properties with
# that are typed as another model or as a typed collection,
for example
Object, are affected. The extension scanner
cannot detect this, since the deprecated behavior is the side effect of an
attribute.
Migration
Replace
# with
# on every property
that should not be validated.
# is not needed to keep a
property out of persistence: Extbase only maps properties that have a matching
column in the TCA. This can be automated with a Rector rule that replaces
# with
# on every property with a
non-simple type.
use TYPO3\CMS\Extbase\Attribute\ORM\Transient;
#[Transient]
protected ?Category $category = null;
use TYPO3\CMS\Extbase\Attribute\IgnoreValidation;
#[IgnoreValidation]
protected ?Category $category = null;
Extensions that also support TYPO3 v13.4 or v14 keep
# next
to
# until they drop support for these versions.
Extbase in TYPO3 v13.4 and v14 does not evaluate unknown property attributes,
so the same code works in TYPO3 v13.4, v14 and v15.