[BUGFIX] Don't set resource storages permanently offline automatically 16/50816/2
authorMarc Willmann <mw@f7.de>
Tue, 25 Oct 2016 15:18:18 +0000 (17:18 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 1 Dec 2016 11:21:23 +0000 (12:21 +0100)
When the storage drive coudn't be initialized correctly the storage is
only put offline for the current request. The error thrown by the driver
is logged to database table sys_log as well.

Resolves: #75184
Releases: master, 7.6
Change-Id: I4b05b732f887c0679e9cdda77793e4b304ac3fdb
Reviewed-on: https://review.typo3.org/50816
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Configuration/DefaultConfiguration.php

index 0df13b1..12e65e5 100644 (file)
@@ -176,9 +176,17 @@ class ResourceStorage implements ResourceStorageInterface
         try {
             $this->driver->processConfiguration();
         } catch (Exception\InvalidConfigurationException $e) {
-            // configuration error
-            // mark this storage as permanently unusable
-            $this->markAsPermanentlyOffline();
+            // Configuration error
+            $this->isOnline = false;
+
+            $message = sprintf(
+                'Failed initializing storage [%d] "%s", error: %s',
+                $this->getUid(),
+                $this->getName(),
+                $e->getMessage()
+            );
+
+            $this->getLogger()->error($message);
         }
         $this->driver->initialize();
         $this->capabilities = $this->driver->getCapabilities();
@@ -2987,4 +2995,26 @@ class ResourceStorage implements ResourceStorageInterface
     {
         return $this->isDefault;
     }
+
+    /**
+     * Returns the current BE user.
+     *
+     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+     */
+    protected function getBackendUser()
+    {
+        return $GLOBALS['BE_USER'];
+    }
+
+    /**
+     * @return \TYPO3\CMS\Core\Log\Logger
+     */
+    protected function getLogger()
+    {
+        /** @var $logManager \TYPO3\CMS\Core\Log\LogManager */
+        $logManager = GeneralUtility::makeInstance(
+            \TYPO3\CMS\Core\Log\LogManager::class
+        );
+        return $logManager->getLogger(get_class($this));
+    }
 }
index e9577fc..99c4993 100644 (file)
@@ -1182,6 +1182,21 @@ return [
             \TYPO3\CMS\Core\Log\LogLevel::WARNING => [
                 \TYPO3\CMS\Core\Log\Writer\FileWriter::class => []
             ]
+        ],
+        'TYPO3' => [
+            'CMS' => [
+                'Core' => [
+                    'Resource' => [
+                        'ResourceStorage' => [
+                            'writerConfiguration' => [
+                                \TYPO3\CMS\Core\Log\LogLevel::ERROR => [
+                                    \TYPO3\CMS\Core\Log\Writer\DatabaseWriter::class => []
+                                ]
+                            ]
+                        ]
+                    ]
+                ]
+            ]
         ]
     ],
     'MODS' => [],