From b228ae8cf8e9faad17e5086b6e9cff9eb70e0615 Mon Sep 17 00:00:00 2001
From: Helmut Hummel <info@helhum.io>
Date: Wed, 25 May 2016 18:28:14 +0200
Subject: [PATCH] [BUGFIX] Output HTML code only if requested

When adding visibility information in DebuggerUtility
it was not respected that this utility can also be used to output in cli.

Add the missing condition and output HTML only if requested.

Additionally when the property has nested objects,
the visibility info must be right after the property not after
every nested object.

Also prettify object type output on command line on the go.

Resolves: #76301
Related: #76008
Releases: master
Change-Id: If82192bf9d1fb0ca1dc843242167d01b1a915f6e
Reviewed-on: https://review.typo3.org/48287
Reviewed-by: Elmar Hinz <t3elmar@gmail.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Elmar Hinz <t3elmar@gmail.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
---
 .../sysext/extbase/Classes/Utility/DebuggerUtility.php | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php b/typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php
index 79c85f8fd36c..e7fed4b16a2b 100644
--- a/typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php
+++ b/typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php
@@ -267,7 +267,7 @@ class DebuggerUtility
             $domainObjectType = 'object';
         }
         if ($plainText) {
-            $dump .= ' ' . self::ansiEscapeWrap(($persistenceType . ' ' . $domainObjectType), '42;30', $ansiColors);
+            $dump .= ' ' . self::ansiEscapeWrap((($persistenceType ? $persistenceType . ' ' : '') . $domainObjectType), '42;30', $ansiColors);
         } else {
             $dump .= '<span class="extbase-debug-ptype">' . ($persistenceType ? $persistenceType . ' ' : '') . $domainObjectType . '</span>';
         }
@@ -335,6 +335,12 @@ class DebuggerUtility
                 }
                 $dump .= PHP_EOL . str_repeat(self::PLAINTEXT_INDENT, $level) . ($plainText ? '' : '<span class="extbase-debug-property">') . self::ansiEscapeWrap($property->getName(), '37', $ansiColors) . ($plainText ? '' : '</span>') . ' => ';
                 $property->setAccessible(true);
+                $visibility = ($property->isProtected() ? 'protected' : ($property->isPrivate() ? 'private' : 'public'));
+                if ($plainText) {
+                    $dump .= ' ' . self::ansiEscapeWrap($visibility, '42;30', $ansiColors) . ' ';
+                } else {
+                    $dump .= '<span class="extbase-debug-visibility">' . $visibility . '</span>';
+                }
                 $dump .= self::renderDump($property->getValue($object), $level, $plainText, $ansiColors);
                 if ($object instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject && !$object->_isNew() && $object->_isDirty($property->getName())) {
                     if ($plainText) {
@@ -343,8 +349,6 @@ class DebuggerUtility
                         $dump .= '<span class="extbase-debug-dirty">modified</span>';
                     }
                 }
-                $visibility = ($property->isProtected() ? 'protected' : ($property->isPrivate() ? 'private' : 'public'));
-                $dump .= '<span class="extbase-debug-visibility">' . $visibility . '</span>';
             }
         }
         return $dump;
-- 
GitLab