class OpcodeCache in Automatic Updates 8
Error if opcode caching is enabled and updates are executed via CLI.
Hierarchy
- class \Drupal\automatic_updates\ReadinessChecker\OpcodeCache implements ReadinessCheckerInterface uses StringTranslationTrait
Expanded class hierarchy of OpcodeCache
1 string reference to 'OpcodeCache'
1 service uses OpcodeCache
File
- src/
ReadinessChecker/ OpcodeCache.php, line 10
Namespace
Drupal\automatic_updates\ReadinessCheckerView source
class OpcodeCache implements ReadinessCheckerInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function run() {
$messages = [];
if ($this
->isCli() && $this
->hasOpcodeFileCache()) {
$messages[] = $this
->t('Automatic updates cannot run via CLI when opcode file cache is enabled.');
}
return $messages;
}
/**
* Determine if PHP is running via CLI.
*
* @return bool
* TRUE if CLI, FALSE otherwise.
*/
protected function isCli() {
return PHP_SAPI === 'cli';
}
/**
* Determine if opcode cache is enabled.
*
* If opcache.validate_timestamps is disabled or enabled with
* opcache.revalidate_freq greater then 2, then a site is considered to have
* opcode caching. The default php.ini setup is
* opcache.validate_timestamps=TRUE and opcache.revalidate_freq=2.
*
* @return bool
* TRUE if opcode file cache is enabled, FALSE otherwise.
*/
protected function hasOpcodeFileCache() {
if (!ini_get('opcache.validate_timestamps')) {
return TRUE;
}
if (ini_get('opcache.revalidate_freq') > 2) {
return TRUE;
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OpcodeCache:: |
protected | function | Determine if opcode cache is enabled. | |
OpcodeCache:: |
protected | function | Determine if PHP is running via CLI. | |
OpcodeCache:: |
public | function |
Run check. Overrides ReadinessCheckerInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |