#110714EXT:opendocs: TrackOpenDocumentsEventListener fatals on CLI (getModuleData() on the session-less _cli_ user)
Description
Every DataHandler write performed on the command line aborts with a fatal error since open document tracking was centralized in EXT:opendocs.
Error: Call to a member function getIdentifier() on null in typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php line 1018
Stack trace (abridged, from an upgrade wizard run):
#0 sysext/opendocs/Classes/Domain/Repository/OpenDocumentRepository.php(145):
AbstractUserAuthentication->getModuleData('opendocs::recent')
#1 sysext/opendocs/Classes/Domain/Repository/OpenDocumentRepository.php(40):
OpenDocumentRepository->migrateLegacyFormatIfNeeded(Object(CommandLineUserAuthentication))
#2 sysext/opendocs/Classes/EventListener/TrackOpenDocumentsEventListener.php(75)
#3 sysext/core/Classes/DataHandling/DataHandler.php(653)
#4 sysext/core/Classes/DataHandling/DataHandler.php(988)
#5 sysext/core/Classes/DataHandling/DataHandler.php(3361)
#6 (extension code calling DataHandler::moveRecord() from an upgrade wizard)
#7 sysext/core/Classes/Command/UpgradeWizardRunCommand.php(269)
Cause
TrackOpenDocumentsEventListener guards its three entry points with:
private function isBackendContext(): bool
{
return ($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
}
On CLI that request is flagged as a backend request, so the guard passes. But
CommandLineUserAuthentication::authenticate() only loads the “cli” user record and never
creates a UserSession, so AbstractUserAuthentication::$userSession stays null and
getModuleData() dereferences null at line 1018.
Steps to reproduce
1. Composer installation of TYPO3 14.3.7 with EXT:opendocs active.
2. Run any CLI command in which DataHandler writes a record – an upgrade wizard, a scheduler
task or a custom command. Observed with the “containerMigrateSorting” wizard of
b13/container via: vendor/bin/typo3 upgrade:run
3. The command aborts with the error above. The same wizard completes normally when run from
Admin Tools > Upgrade > Upgrade Wizards, where the backend user has a session.
Expected
There is no recent documents list on CLI, so the listener should do nothing there instead of
fataling and taking the whole command down with it.
Regression
The listener was introduced with https://review.typo3.org/c/Packages/TYPO3.CMS/+/92707
(“[TASK] Centralize open document tracking in EXT:opendocs”). Before that, opendocs did not
react to DataHandler writes and CLI runs were unaffected.
Suggested fix
Bail out early in isBackendContext():
if (Environment::isCli()) {
return false;
}
This mirrors the guard core already has in BackendUtility::setUpdateSignal(), whose comment
documents exactly this class of failure:
// A CLI use does not need to update the pagetree or anything else // Otherwise DataHandler hook in EXT:redirects in SlugService will throw an error
Reviews 2
History 24
-
Gerrit Code Review pushed patch set 2 for main to change 95858 status
NewUnder Review <span data-processor="relativetime" data-value="2026-09-15T13:51:44+00:00" > 09/15/26, 13:51 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 96005 <span data-processor="relativetime" data-value="2026-09-23T16:42:56+00:00" > 09/23/26, 16:42 </span>
-
Anonymous commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-09-23T16:45:12+00:00" > 09/23/26, 16:45 </span> -
Georg Ringer changed Duplicated by #110855 <span data-processor="relativetime" data-value="2026-10-11T20:31:41+00:00" > 10/11/26, 20:31 </span>
Applied in changeset commit:2af324d1124bd252eddab00c167062f87acd7623.