Deprecation: #97244 - Direct instantiation of CompositeExpression
See forge#97244
Description
doctrine/
deprecated direct instantiation of
Composite
in favour of moving forward to an immutable class implementation. Therefore, this
has also been deprecated in the Core facade class (
\TYPO3\
),
to avoid shifting too far away.
Impact
Instantiating directly with
new Composite
will trigger a PHP
E_
error.
The extension scanner cannot detect direct instantiation of this class.
Affected Installations
In general, instances with extensions that directly instantiate a composite
expression with
new Composite
.
The extension scanner will not find and report direct instantiating.
Migration
Instead of directly instantiating a composite expression with the type as
the first argument and an array of expressions as the second argument, the new
static methods
and
and
or
have to be used.
Note
The static replacement methods
Composite
and
Composite
have already been added in
a forward-compatible way in TYPO3 v11. Thus giving extension developers
the ability to adopt new methods and still being able to support
multiple Core versions without workarounds.
For example, following code:
use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
$compositeExpressionAND = new CompositeExpression(
CompositeExpression::TYPE_AND,
[
// expressions ...
]
);
$compositeExpressionOR = new CompositeExpression(
CompositeExpression::TYPE_OR,
[
// expressions ...
]
);
should be replaced with:
use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
// Note the spread operator
$compositeExpressionAND = CompositeExpression::and(
...[
// expressions ...
]
);
$compositeExpressionOR = CompositeExpression::or(
...[
// expressions ...
]
);