You are here

public function D8Cache::ensureInstalled in Drupal 8 Cache Backport 7

Ensure D8Cache is installed properly.

This will preload d8cache.module during page cache serving, and ensure it is properly installed in other circumstances.

Return value

bool FALSE if it appears d8cache is incorrectly installed, otherwise TRUE.

2 calls to D8Cache::ensureInstalled()
D8Cache::checksumValid in ./d8cache.cache.inc
Returns whether the checksum is valid for the given cache tags.
D8Cache::getCurrentChecksum in ./d8cache.cache.inc
Returns the sum total of validations for a given set of tags.

File

./d8cache.cache.inc, line 304

Class

D8Cache
Defines a Drupal 8 cacheable metadata aware cache backend.

Code

public function ensureInstalled() {
  static $installStateKnown = FALSE;
  static $isInstalled = TRUE;
  if ($this->bin == 'cache_page' && drupal_get_bootstrap_phase() < DRUPAL_BOOTSTRAP_FULL) {

    // Ensure the module file is loaded, in case we are serving a cached page.
    require_once __DIR__ . '/d8cache.module';

    // When we haven't fully bootstrapped yet, we can't actually verify that
    // d8cache has been installed properly. Just assume things are OK.
    return TRUE;
  }
  if ($installStateKnown) {
    return $isInstalled;
  }
  if (!module_exists('d8cache')) {
    watchdog('d8cache', 'D8Cache Backend is in use, but the d8cache module has not been enabled! Please enable it to ensure cache tags work properly.', array(), WATCHDOG_ALERT, 'admin/modules');
    $isInstalled = FALSE;
  }
  $installStateKnown = TRUE;
  return $isInstalled;
}