From cad25b228a2efebebcd941e127ed5ddc258b6e4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20E=C3=9Fl?= <indy.essl@gmail.com>
Date: Sun, 1 Mar 2020 11:55:47 +0100
Subject: [PATCH] [BUGFIX] Fix handling of type "comment" in TypoScript
 Constant Editor
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

According to the documentation, the boolean checkbox for type "comment"
should behave in the following way:
- checked= “”
- not-checked = “#”

The handling of this behaviour was faulty in the TypoScript Constant
Editor. This means, every time the constants were saved without changing
the "comment" checkbox, its value was reversed.
Further information:
https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/UsingSetting/TheConstantEditor.html

Resolves: #82208
Releases: master, 9.5
Change-Id: I1473b435e37b47c4563f0d245e09b1680c738bcd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63518
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../Classes/TypoScript/ExtendedTemplateService.php     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php b/typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
index 39d66a4446a8..a544e7d49423 100644
--- a/typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
+++ b/typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
@@ -1073,11 +1073,11 @@ class ExtendedTemplateService extends TemplateService
                                 . '</label>';
                             break;
                         case 'comment':
-                            $sel = $fV ? 'checked' : '';
+                            $sel = $fV ? '' : 'checked';
                             $p_field =
-                                '<input type="hidden" name="' . $fN . '" value="#" />'
+                                '<input type="hidden" name="' . $fN . '" value="" />'
                                 . '<label class="btn btn-default btn-checkbox">'
-                                . '<input id="' . $idName . '" type="checkbox" name="' . $fN . '" value="" ' . $sel . ' onClick="uFormUrl(' . $aname . ')" />'
+                                . '<input id="' . $idName . '" type="checkbox" name="' . $fN . '" value="1" ' . $sel . ' onClick="uFormUrl(' . $aname . ')" />'
                                 . '<span class="t3-icon fa"></span>'
                                 . '</label>';
                             break;
@@ -1362,9 +1362,9 @@ class ExtendedTemplateService extends TemplateService
                                 break;
                             case 'comment':
                                 if ($var) {
-                                    $var = '#';
-                                } else {
                                     $var = '';
+                                } else {
+                                    $var = '#';
                                 }
                                 break;
                             case 'wrap':
-- 
GitLab