From 7d469851d00f8687b51708182ad87627f15250c1 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Tue, 20 Jun 2017 11:00:58 +0200
Subject: [PATCH] [BUGFIX] Populate loaded commands after ext_tables is loaded

Especially in TYPO3 v8, where TCA is not loaded at all times,
running a CLI command with an empty cache will result in
errors, but for the sake of clean structure, the commands
will be populated when executing the actual command.

Resolves: #80897
Releases: master, 8.7
Change-Id: I7ad33ca86724d94f451c44f68538d5d38e343636
Reviewed-on: https://review.typo3.org/53270
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Thomas Maroschik <tmaroschik@dfau.de>
Tested-by: Thomas Maroschik <tmaroschik@dfau.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
---
 typo3/sysext/core/Classes/Console/CommandRequestHandler.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/Console/CommandRequestHandler.php b/typo3/sysext/core/Classes/Console/CommandRequestHandler.php
index e217e3c6497f..f583be932dab 100644
--- a/typo3/sysext/core/Classes/Console/CommandRequestHandler.php
+++ b/typo3/sysext/core/Classes/Console/CommandRequestHandler.php
@@ -68,6 +68,8 @@ class CommandRequestHandler implements RequestHandlerInterface
             // Make sure output is not buffered, so command-line output and interaction can take place
             ->endOutputBufferingAndCleanPreviousOutput();
 
+        $this->populateAvailableCommands();
+
         $exitCode = $this->application->run($input, $output);
         exit($exitCode);
     }
@@ -80,7 +82,6 @@ class CommandRequestHandler implements RequestHandlerInterface
      */
     public function canHandleRequest(InputInterface $input)
     {
-        $this->populateAvailableCommands();
         return true;
     }
 
-- 
GitLab