[TASK] Do not throw exception on unavailable APC(u) cache backend 85/52785/2
authortbringewatt <t.bringewatt@mittwald.de>
Fri, 3 Feb 2017 14:45:02 +0000 (15:45 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 11 May 2017 20:03:48 +0000 (22:03 +0200)
Log an error (keeping the website available) instead of throwing an
exception (and thus completely disabling it) if TYPO3 is configured to
use the APC / APCu cache backend but saving data to the cache failed.

Resolves: #79636
Releases: master, 8.7

Change-Id: I3adf829825017a3061e921d5d3ec74f20e18311e
Reviewed-on: https://review.typo3.org/52785
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Cache/Backend/ApcBackend.php
typo3/sysext/core/Classes/Cache/Backend/ApcuBackend.php

index dd51ab2..dc6cfa2 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * A caching backend which stores cache entries by using APC.
  *
@@ -144,7 +146,8 @@ class ApcBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implement
             $this->removeIdentifierFromAllTags($entryIdentifier);
             $this->addIdentifierToTags($entryIdentifier, $tags);
         } else {
-            throw new \TYPO3\CMS\Core\Cache\Exception('Could not set value.', 1232986877);
+            $errorMessage = 'Error using APCu: Could not save data in the cache.';
+            GeneralUtility::sysLog($errorMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
         }
     }
 
index 445d5cb..3e550b1 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\Cache;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -145,7 +146,8 @@ class ApcuBackend extends AbstractBackend implements TaggableBackendInterface
             $this->removeIdentifierFromAllTags($entryIdentifier);
             $this->addIdentifierToTags($entryIdentifier, $tags);
         } else {
-            throw new Cache\Exception('Could not set value.', 1232986277);
+            $errorMessage = 'Error using APCu: Could not save data in the cache.';
+            GeneralUtility::sysLog($errorMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
         }
     }