From 187208e37e343e2ca9b9d789f2e709b53f2cdf9e Mon Sep 17 00:00:00 2001
From: Torben Hansen <derhansen@gmail.com>
Date: Fri, 24 Mar 2023 15:39:19 +0100
Subject: [PATCH] [BUGFIX] Respect default value for confirmation in
 ext:install

The default value for a confirmation is currently not respected
in the install tool on UI level and a confirmation dialog will
always show the "deny" button as selected. On CLI level the
default value is however taken into account.

This change sets the default value of the confirm dialog buttons
depending on the `defaultValue` property of the confirmation. If
the `defaultValue` is `true`, the "confirm" button is selected,
otherwise the "deny" button is selected.

Resolves: #100291
Releases: main, 11.5
Signed-off-by: Torben Hansen <derhansen@gmail.com>
Change-Id: Iee6e89c61cc5ad7117f7e565b42d39bd82ce26f9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78248
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
---
 .../install/Classes/Service/UpgradeWizardsService.php       | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
index 092dad4c88ca..b02f4bb0fff7 100644
--- a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
+++ b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php
@@ -333,11 +333,13 @@ class UpgradeWizardsService
             $markup[] = '        <p>' . nl2br(htmlspecialchars($updateObject->getConfirmation()->getMessage())) . '</p>';
             $markup[] = '        <div class="btn-group">';
             if (!$updateObject->getConfirmation()->isRequired()) {
-                $markup[] = '        <input ' . GeneralUtility::implodeAttributes($radioAttributes, true) . ' checked id="upgrade-wizard-deny">';
+                $denyChecked = $updateObject->getConfirmation()->getDefaultValue() === false ? ' checked' : '';
+                $markup[] = '        <input ' . GeneralUtility::implodeAttributes($radioAttributes, true) . $denyChecked . ' id="upgrade-wizard-deny">';
                 $markup[] = '        <label class="btn btn-default" for="upgrade-wizard-deny">' . $updateObject->getConfirmation()->getDeny() . '</label>';
             }
             $radioAttributes['value'] = '1';
-            $markup[] = '            <input ' . GeneralUtility::implodeAttributes($radioAttributes, true) . ' id="upgrade-wizard-confirm">';
+            $confirmChecked = $updateObject->getConfirmation()->getDefaultValue() === true ? ' checked' : '';
+            $markup[] = '            <input ' . GeneralUtility::implodeAttributes($radioAttributes, true) . $confirmChecked . ' id="upgrade-wizard-confirm">';
             $markup[] = '            <label class="btn btn-default" for="upgrade-wizard-confirm">' . $updateObject->getConfirmation()->getConfirm() . '</label>';
             $markup[] = '        </div>';
             $markup[] = '    </div>';
-- 
GitLab