You are here

function authcache_requirements in Authenticated User Page Caching (Authcache) 7.2

Same name and namespace in other branches
  1. 7 authcache.install \authcache_requirements()

Implements hook_requirements().

File

./authcache.install, line 20
Install, update and uninstall functions for the authcache module.

Code

function authcache_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();

  // Check hook_authcache_backend_cache_save implementation.
  $modules = module_implements('authcache_backend_cache_save');
  if (empty($modules)) {
    $requirements['authcache'] = array(
      'value' => $t('No cache backend enabled'),
      'description' => $t('None of the enabled modules implements hook_authcache_backend_cache_save(). This means that page caching will not have any effect. You should enable a module which implements this hook, e.g., authcache_builtin or authcache_varnish.'),
      'severity' => REQUIREMENT_WARNING,
    );
  }
  else {
    $requirements['authcache'] = array(
      'value' => $t('hook_authcache_backend_cache_save() implemented: @modules', array(
        '@modules' => implode(', ', $modules),
      )),
      'severity' => REQUIREMENT_OK,
    );
  }
  $requirements['authcache']['title'] = $t('Authcache');
  $roles = variable_get('authcache_roles', array());
  if (count($roles) && (variable_get('cache') || variable_get('page_cache_without_database'))) {
    $message = '<p>' . $t('Drupal core page caching for anonymous users does not work properly when Authcache is enabled. Please either deactivate Drupal core page caching or disable Authcache.') . '</p>';
    if (!isset($roles[DRUPAL_ANONYMOUS_RID])) {
      $message .= '<p>' . $t('You may enable the page cache for anonymous users by <a href="!link">configuring</a> Authcache for anonymous users', array(
        '!link' => url('admin/config/system/authcache'),
      )) . '</p>';
    }
    if (variable_get('page_cache_without_database')) {
      $message .= '<p>' . $t('Furthermore it seems that !setting is enabled. Please remove that line from !file, otherwise Authcache will not work properly.', array(
        '!setting' => '<code>$conf[\'page_cache_without_database\']</code>',
        '!file' => '<code>' . conf_path() . '/settings.php</code>',
      )) . '</p>';
    }
    $requirements['authcache-vs-core-cache'] = array(
      'title' => $t('Authcache and Core Page Cache'),
      'value' => $t('Conflict with <a href="!link">Drupal core page caching</a>', array(
        '!link' => url('admin/config/development/performance'),
      )),
      'description' => $message,
      'severity' => $phase === 'runtime' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING,
    );
  }
  return $requirements;
}