---
title: "Deprecation: #97244 - Direct instantiation of CompositeExpression"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:deprecation-97244-1"
source: "Changelog/12.0/Deprecation-97244-DirectInstantiationOfCompositeExpression.rst"
typo3-version: "12.0"
typo3-major: 12
type: "deprecation"
issue: 97244
forge: "https://forge.typo3.org/issues/97244"
tags: ["Database", "NotScanned", "ext:core"]
rendered: "2026-09-24T12:29:17+00:00"
---

# Deprecation: #97244 - Direct instantiation of CompositeExpression {#deprecation-97244-1}

See [forge#97244](https://forge.typo3.org/issues/97244)

## Description {#description}

`doctrine/dbal` [deprecated](https://github.com/doctrine/dbal/commit/7bcd6ebcc2d30ba96cf00d3dca2345d6ae779cf9) 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 {#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 {#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 {#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:

```php
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:

```php
use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;

// Note the spread operator
$compositeExpressionAND = CompositeExpression::and(
    ...[
        // expressions ...
    ]
);

$compositeExpressionOR = CompositeExpression::or(
    ...[
        // expressions ...
    ]
);
```
