Issue Bug Resolved

#110773TYPO3 does not handle pages.title or pages.nav_title NULL well, might result in exception

Sybille Peters 09/24/26, 13:01 updated 09/25/26, 17:50

Description

I noticed this in TYPO3 v13 (latest version), but it looks like it might also be the case in TYPO3 v15 (due to a glance in the code).

The code : Pages/TreeController::pagesToFlatArray:

  • does not check for pages[‘title’] is NULL, just assigns
  • check for $page[‘nav_title’] is NULL in if statement (with null coalesce) but then just assigns without null coalesce

It seems odd that on the one hand null coalesce is used in the if statement but then it is just assigned anyhow.

Source code:

$visibleText = $page['title'];
if ($this->useNavTitle && trim($page['nav_title'] ?? '') !== '') {
            $nameSourceField = 'nav_title';
            $visibleText = $page['nav_title'];
}

The exception occurs here:

if (trim($visibleText) === '') {

I excecuted all upgrade wizards and database compare but I still have some pages with pages.title is NULL:

 select uid,title,nav_title from pages where title is null or nav_title is null and not deleted;
+--------+-------+-----------+
| uid    | title | nav_title |
+--------+-------+-----------+
| 118616 | NULL  |           |
| 119373 | NULL  |           |
| 121289 | NULL  |           |
| 121290 | NULL  |           |
+--------+-------+-----------+

I think I did already fix this in the DB a while ago by setting all NULL title fields to empty string (it might have been nav_title, not title though), so it looks like a recurring issue. I currently don’t know how or why pages.title or nav_title are set to NULL.

Result

Problem manifests itself with errors in log, probably also messages in the BE.

for TYPO3 13.5.35:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: trim(): Argument #1 (closed) ($string) must be of type string, null given | TypeError
thrown in file
/var/www/www.mysite.de/releases/389/vendor/typo3/cms-backend/Classes/Controller/Page/TreeController.php in line 365.
Requested URL: https://mysite.de/typo3/ajax/page/tree/fetchData?token=--AnonymizedToken--&parent=78044&mount=0&depth=2

Reviews 3

History 36

  1. Wolfgang Klinger commented <span data-processor="relativetime" data-value="2026-09-25T12:59:15+00:00" > 09/25/26, 12:59 </span>

    In a default installation those fields can’t be NULL. Both pages.title and pages.nav_title are plain type=input fields without nullable, so the TCA generated schema declares them varchar DEFAULT '' NOT NULL, and the DataHandler writes an empty string for a cleared field. NULL rows like yours are leftovers from somewhere else or a manual change, and the “database compare” should convert the column probably (after you updated the values).

    The code is inconsistent though: the nav_title check uses a null coalesce and the two title assignments don’t. I pushed a small patch that adds the guard to both, deliberately without a test, since the core schema can’t produce the case.

  2. Sybille Peters commented <span data-processor="relativetime" data-value="2026-09-25T15:01:13+00:00" > 09/25/26, 15:01 </span>

    Thanks. I realized what I wrote above partly does not make sense since for nav_title the part inside the if block would not get executed if nav_title is not set.

    I don’t know why my database fields are set the way they are. It might be that an extension messed this up. I fixed it now, setting title to empty string if NULL, It is also a bit weird that title is empty in the first place.

    If this is really an edge case and not really a problem I could also close here. Or wait for the reviews on the patch.

  3. Wolfgang Klinger commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-25T17:50:13+00:00" > 09/25/26, 17:50 </span>

    Applied in changeset commit:adc261d80beb9fd14dbea02a13630ca211709e0e.