[BUGFIX] Cache file could not be written on concurrent actions 98/19898/2
authorOliver Hader <oliver@typo3.org>
Sat, 13 Apr 2013 10:54:12 +0000 (12:54 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Sat, 13 Apr 2013 11:10:05 +0000 (13:10 +0200)
The hook to clear the language (l10n) caches is currently called
every time any element in the backend is modified. If concurrent
actions take place, flushing and regenerating this cache results
in an accordant exception like

The cache file ".../t3lib_l10n/3e2cbbda0301cf592e5831ef26c56b7b"
could not be written.

The solution is to only execute this hook if all or the temp.
caches shall be cleared

Change-Id: Iaf68f50e2f9bfcc3ffce64a0f5267673afd332ad
Fixes: #46205
Releases: 4.7, 6.0, 6.1
Reviewed-on: https://review.typo3.org/19898
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/lang/Classes/LanguageCacheClearer.php

index f26bbc5..08b4cff 100644 (file)
@@ -55,14 +55,21 @@ class LanguageCacheClearer {
        }
 
        /**
-        * Flush the l10n cache
+        * Flush the l10n cache if the clear cache command "all" or "temp_cached" is given.
         *
+        * @param array $parameters Parameters as defined in DataHandler
         * @return void
         */
-       public function clearCache() {
-               if (isset($GLOBALS['BE_USER'])) {
+       public function clearCache(array $parameters) {
+               $isValidCall = (
+                       !empty($parameters['cacheCmd'])
+                       && \TYPO3\CMS\Core\Utility\GeneralUtility::inList('all,temp_cached', empty($parameters['cacheCmd']))
+               );
+
+               if (isset($GLOBALS['BE_USER']) && $isValidCall) {
                        $GLOBALS['BE_USER']->writelog(3, 1, 0, 0, '[lang]: User %s has cleared the language cache', array($GLOBALS['BE_USER']->user['username']));
                }
+
                $this->cacheInstance->flush();
        }