You are here

authcache_builtin.install in Authenticated User Page Caching (Authcache) 7.2

Install, update and uninstall functions for the Authcache Bultin module.

File

modules/authcache_builtin/authcache_builtin.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Authcache Bultin module.
 */

/**
 * Implements hook_requirements().
 */
function authcache_builtin_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();
  $requirements['authcache_builtin'] = array(
    'title' => $t('Authcache builtin cache backend'),
  );

  // Retrieve the name of the cache class used for the cache_page bin.
  $page_cache_class = get_class(_cache_get_object('cache_page'));
  if (_authcache_builtin_backendstatus()) {
    $requirements['authcache_builtin']['value'] = $t('Using %class as cache backend', array(
      '%class' => $page_cache_class,
    ));
  }
  else {
    $requirements['authcache_builtin']['value'] = $t('Either authcache.inc is missing or authcache_builtin.cache.inc is not the last entry in cache_backends variable.');
    $requirements['authcache_builtin']['description'] = $t('Your settings.php file must be modified to enable Authcache builtin cache backend. See <a href="@url">README.txt</a>.', array(
      '@url' => base_path() . drupal_get_path('module', 'authcache_builtin') . '/README.txt',
    ));
    $requirements['authcache_builtin']['severity'] = $phase === 'runtime' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING;
  }
  return $requirements;
}

/**
 * Return TRUE if settings.php is properly configured.
 *
 * Verify that authcache_builtin.cache.inc is the last entry in the
 * cache_backends array.
 *
 * @return bool
 *   TRUE if the configuration is sane, FALSE otherwise.
 */
function _authcache_builtin_backendstatus() {

  // Check whether authcache.inc is last in cache_backends.
  $backends = variable_get('cache_backends', array());
  $last_in_backends = end($backends);
  $authcache_builtin_inc = drupal_get_path('module', 'authcache_builtin') . '/authcache_builtin.cache.inc';
  $authcache_main_inc = drupal_get_path('module', 'authcache') . '/authcache.cache.inc';
  return $authcache_builtin_inc === $last_in_backends && in_array($authcache_main_inc, $backends);
}

Functions

Namesort descending Description
authcache_builtin_requirements Implements hook_requirements().
_authcache_builtin_backendstatus Return TRUE if settings.php is properly configured.