[BUGFIX] Allow silent upgrade service to migrate old displayErrors setting 19/55619/3
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 8 Feb 2018 20:08:26 +0000 (21:08 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 8 Feb 2018 20:58:50 +0000 (21:58 +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/55619
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php

index 94d2996..6c43efe 100644 (file)
@@ -625,11 +625,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 cea75a4..62f53d1 100644 (file)
@@ -150,6 +150,7 @@ class SilentConfigurationUpgradeService
         $this->migrateLangDebug();
         $this->migrateCacheHashOptions();
         $this->migrateExceptionErrors();
+        $this->migrateDisplayErrorsSetting();
 
         // Should run at the end to prevent that obsolete settings are removed before migration
         $this->removeObsoleteLocalConfigurationSettings();
@@ -890,4 +891,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 (MissingArrayPathException $e) {
+            // no change inside the LocalConfiguration.php found, so nothing needs to be modified
+        }
+    }
 }