[BUGFIX] Warn about apc.enable_cli=0 on command line 35/28035/4
authorChristian Weiske <christian.weiske@netresearch.de>
Tue, 4 Mar 2014 13:18:50 +0000 (14:18 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 7 Mar 2014 13:59:34 +0000 (14:59 +0100)
When running a CLI script via typo3/cli_dispatch.phpsh,
using the APC caching backend will lead to errors like
> TYPO3 Exception #1232986877: Could not set value.

This patch checks if TYPO3 is running on CLI, and validates the
apc.enable_cli setting to give a proper error message.

Change-Id: Icbeb619fc2054634274b492df94dbbc89958a8b6
Resolves: #25274
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/28035
Reviewed-by: Ernesto Baschny
Reviewed-by: Andreas Fernandez
Tested-by: Andreas Fernandez
Reviewed-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Cache/Backend/ApcBackend.php

index 5c1bc5c..bb04fdd 100644 (file)
@@ -89,6 +89,9 @@ class ApcBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implement
                if (!extension_loaded('apc')) {
                        throw new \TYPO3\CMS\Core\Cache\Exception('The PHP extension "apc" or "apcu" must be installed and loaded in order to use the APC backend.', 1232985414);
                }
+               if (PHP_SAPI === 'cli' && ini_get('apc.enable_cli') == 0) {
+                       throw new \TYPO3\CMS\Core\Cache\Exception('The APC backend cannot be used because apc is disabled on CLI.', 1232985415);
+               }
                parent::__construct($context, $options);
        }