Bug #82621

The APCu backend cannot be used because apcu is disabled on CLI.

Added by R3 H6 over 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
CLI
Target version:
-
Start date:
2017-09-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Uncaught TYPO3 Exception #1232985915: The APCu backend cannot be used because apcu is disabled on CLI.
thrown in file /home/alcosuis/public_html/staging2.alcosuisse.ch/typo3_src-8.7.6/typo3/sysext/core/Classes/Cache/Backend/ApcuBackend.php
in line 84

If it is not possible to use it, the system should fallback to database for CLI.
Change the configuration in install tool is not the best solution...


Related issues

Related to TYPO3 Core - Task #78140: Disable APCu on CLI, if it was added to LocalConfiguration.php automatically while installing TYPO3 New2016-10-04

Actions
#1

Updated by Mathias Schreiber over 4 years ago

Out of curiosity: Why did you configure APCu for TYPO3 and did not enable it for CLI?
A fallback makes little to no sense, if you want to warm up caches via CLI that are then not used in the frontend.

I seem to miss something here, please try to describe your usecase in a bit more detail.

#2

Updated by R3 H6 over 4 years ago

You're right. It's probably not an issue of TYPO3.
Checking with Hoster for PHP settings...
Can probably be closed.
Thanks for the quick response.

#3

Updated by Mathias Schreiber over 4 years ago

  • Status changed from New to Resolved

Ok, glad I could help.
I will close the issue now, if we need to re-open it, don't hesitate to comment here or hit me up on Slack.
Enjoy the weekend :)

#4

Updated by Oliver Hader over 4 years ago

Side-note: Fresh TYPO3 installations will use APCu if it's available for the web-context (see ApcuPreset), and PHP 7.1 (at least on Ubuntu 17.10) does not enable the according flag in PHP-CLI per default.

Work-around (example for Ubuntu 17.10):
Modify /etc/php/7.1/cli/conf.d/20-apcu.ini
Add apc.enable_cli=on

#5

Updated by Benni Mack over 3 years ago

  • Status changed from Resolved to Closed
#6

Updated by Dirk Wenzel over 3 years ago

IMHO this issue is not solved and it is a TYPO3 issue:

  • if APCu is available it is recommend as Extbase-Object-Cache in the Installtool in the Configuration Presets
  • the constructor of `TYPO3\CMS\Core\Cache\Backend\ApcuBackend` throws an Execption if `PHP_SAPI === 'cli' && ini_get('apc.enable_cli') == 0` allthough
  • the documentation for `apc.enable_cli` [1] says
    Mostly for testing and debugging. Setting this enables APC for the CLI version of PHP. 
    Under normal circumstances, it is not ideal to create, populate and destroy the APC cache on every CLI request,
    but for various test scenarios it is useful to be able to enable APC for the CLI version of PHP easily. 
    
  • if enabled for the CLI, APCu will most probably have no positive effect since the cache is created, populated AND destroyed for each call (and not re-used later on)
My conclusion is TYPO3 should :
  • silently ignore the APCu-cache in CLI (use NullBackend instead)
  • optionally log a message

see https://forge.typo3.org/issues/78140

[1] http://php.net/manual/en/apc.configuration.php#ini.apc.enable-cli

#7

Updated by Felix Nagel over 2 years ago

I agree with Dirk Wenzel. Most hosters do not allow APCu on CLI.

#8

Updated by Benni Mack over 2 years ago

  • Related to Task #78140: Disable APCu on CLI, if it was added to LocalConfiguration.php automatically while installing TYPO3 added
#9

Updated by Sascha no-lastname-given over 1 year ago

My workaround is to change the following to AdditionalConfiguration.php

if (php_sapi_name() == 'cli') {
    /** @var ConfigurationManager $configurationManager */
    $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching'] = $configurationManager->getDefaultConfiguration()['SYS']['caching'];
}

Also available in: Atom PDF