diff --git a/typo3/sysext/core/Classes/Authentication/CommandLineUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/CommandLineUserAuthentication.php
index e8d3be88ac3847bc797e418f881014fa994395d9..f8fc26910fdd6d20d12d65bc3d26aa82975c41f7 100644
--- a/typo3/sysext/core/Classes/Authentication/CommandLineUserAuthentication.php
+++ b/typo3/sysext/core/Classes/Authentication/CommandLineUserAuthentication.php
@@ -73,6 +73,14 @@ class CommandLineUserAuthentication extends BackendUserAuthentication
         // do nothing
     }
 
+    /**
+     * On CLI there is no session and no switched user
+     */
+    public function getOriginalUserIdWhenInSwitchUserMode(): ?int
+    {
+        return null;
+    }
+
     /**
      * Logs-in the _CLI_ user. It does not need to check for credentials.
      *