[BUGFIX] Allow silent upgrade service to migrate old displayErrors setting 20/55620/3
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 8 Feb 2018 21:11:20 +0000 (22:11 +0100)
committerBenni Mack <benni@typo3.org>
Thu, 8 Feb 2018 21:35:14 +0000 (22:35 +0100)
The bootstrap throws an exception when the setting SYS/displayErrors
is not set to "-1", "0" or "1". In the Install Tool TYPO3 should not crash.
Instead allow to silently migrate the value to -1

Resolves: #82782
Resolves: #83787
Releases: master,8.7
Change-Id: Ie0180b34a551a81667bb4ac32c6ab2699d9b3d4f
Reviewed-on: https://review.typo3.org/55620
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php

index 9af4663..825fd08 100644 (file)
@@ -650,11 +650,13 @@ class Bootstrap
                 $displayErrors = 1;
                 break;
             default:
-                // Throw exception if an invalid option is set.
-                throw new \RuntimeException(
-                    'The option $TYPO3_CONF_VARS[SYS][displayErrors] is not set to "-1", "0" or "1".',
-                    1476046290
-                );
+                if (!TYPO3_REQUESTTYPE_INSTALL) {
+                    // Throw exception if an invalid option is set.
+                    throw new \RuntimeException(
+                        'The option $TYPO3_CONF_VARS[SYS][displayErrors] is not set to "-1", "0" or "1".',
+                        1476046290
+                    );
+                }
         }
         @ini_set('display_errors', $displayErrors);
 
index 1e78518..b32d41e 100644 (file)
@@ -119,6 +119,7 @@ class SilentConfigurationUpgradeService
         $this->migrateDatabaseConnectionCharset();
         $this->migrateDatabaseDriverOptions();
         $this->migrateLangDebug();
+        $this->migrateDisplayErrorsSetting();
 
         // Should run at the end to prevent that obsolete settings are removed before migration
         $this->removeObsoleteLocalConfigurationSettings();
@@ -779,4 +780,21 @@ class SilentConfigurationUpgradeService
             // no change inside the LocalConfiguration.php found, so nothing needs to be modified
         }
     }
+
+    /**
+     * Migrate SYS/displayErrors to not contain 2
+     */
+    protected function migrateDisplayErrorsSetting()
+    {
+        $confManager = $this->configurationManager;
+        try {
+            $currentOption = (int)$confManager->getLocalConfigurationValueByPath('SYS/displayErrors');
+            // make sure displayErrors is set to 2
+            if ($currentOption === 2) {
+                $confManager->setLocalConfigurationValueByPath('SYS/displayErrors', -1);
+            }
+        } catch (\RuntimeException $e) {
+            // no change inside the LocalConfiguration.php found, so nothing needs to be modified
+        }
+    }
 }