#110773TYPO3 does not handle pages.title or pages.nav_title NULL well, might result in exception
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
-
Gerrit Code Review pushed patch set 1 for main to change 96072 status
NewUnder Review <span data-processor="relativetime" data-value="2026-09-25T12:57:35+00:00" > 09/25/26, 12:57 </span> -
Wolfgang Klinger commented <span data-processor="relativetime" data-value="2026-09-25T12:59:15+00:00" > 09/25/26, 12:59 </span>
-
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.
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 96087 <span data-processor="relativetime" data-value="2026-09-25T17:36:06+00:00" > 09/25/26, 17:36 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 96088 <span data-processor="relativetime" data-value="2026-09-25T17:36:17+00:00" > 09/25/26, 17:36 </span>
-
Wolfgang Klinger commented and changed status
Under ReviewResolved done0 %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.
In a default installation those fields can’t be
NULL. Bothpages.titleandpages.nav_titleare plaintype=inputfields withoutnullable, so the TCA generated schema declares themvarchar 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.