From 775c437021bc69fcc4b93a7bbeb97afe0e53a30c Mon Sep 17 00:00:00 2001
From: Georg Ringer <georg.ringer@gmail.com>
Date: Fri, 27 Mar 2020 01:01:45 +0100
Subject: [PATCH] [BUGFIX] Output more helpful information in
 OrphanRecordsCommand

Show the detailed information about how many orphaned records have been
found in which table by default and don't hide it behind a verbose flag.

Additionally also show the ids of those records.

Resolves: #87777
Releases: master, 9.5
Change-Id: I112b3d128109ea9bab358d9cbe215c0f5d45a820
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63940
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../lowlevel/Classes/Command/OrphanRecordsCommand.php    | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php b/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php
index c1ebdcc2cdd9..c264ed27e557 100644
--- a/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php
+++ b/typo3/sysext/lowlevel/Classes/Command/OrphanRecordsCommand.php
@@ -109,22 +109,17 @@ Manual repair suggestions:
                 ->orderBy('uid')
                 ->execute();
 
-            $totalOrphans = 0;
             $rowCount = $queryBuilder->count('uid')->execute()->fetchColumn(0);
             if ($rowCount) {
                 $orphans[$tableName] = [];
                 while ($orphanRecord = $result->fetch()) {
                     $orphans[$tableName][$orphanRecord['uid']] = $orphanRecord['uid'];
                 }
-                $totalOrphans += count($orphans[$tableName]);
 
-                if ($io->isVeryVerbose() && count($orphans[$tableName])) {
-                    $io->writeln('Found ' . count($orphans[$tableName]) . ' orphan records in table "' . $tableName . '".');
+                if (count($orphans[$tableName])) {
+                    $io->note('Found ' . count($orphans[$tableName]) . ' orphan records in table "' . $tableName . '" with following ids: ' . implode(', ', $orphans[$tableName]));
                 }
             }
-            if (!$io->isQuiet() && $totalOrphans) {
-                $io->note('Found ' . $totalOrphans . ' records in ' . count($orphans) . ' database tables.');
-            }
         }
 
         if (count($orphans)) {
-- 
GitLab