Deprecation: #97244 - Direct instantiation of CompositeExpression¶
See forge#97244
Description¶
doctrine/dbal
deprecated direct instantiation of CompositeExpression
in favour of moving forward to an immutable class implementation. Therefore, this
has also been deprecated in the Core facade class (\TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression
),
to avoid shifting too far away.
Impact¶
Instantiating directly with new CompositeExpression(...)
will trigger a PHP E_USER_DEPRECATED
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 CompositeExpression(...)
.
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 CompositeExpression::and()
and CompositeExpression::or()
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 ...
]
);