You are here

function panels_content_cache_requirements in Panels Content Cache 7

Implements hook_requirements().

File

./panels_content_cache.install, line 10
Installation, schema and update hooks.

Code

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

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

    // The module requires versions of the Panels module that include the cache
    // table.
    if (!db_table_exists('cache_panels')) {
      $requirements['panels_content_cache'] = array(
        'severity' => REQUIREMENT_ERROR,
        'title' => 'Panels Content Cache',
        'value' => $t('Panels v7.x-3.4 or newer is required'),
        'description' => $t('The Panels module must be updated to v7.x-3.4 or newer.'),
      );
    }

    // Warn about the core bug and the Cache Consistency module.
    if (!empty($GLOBALS['conf']['cache_backends'])) {
      foreach ($GLOBALS['conf']['cache_backends'] as $cache_backend) {
        foreach (array(
          'memcache',
          'redis',
        ) as $cache_module) {
          if (strpos($cache_backend, $cache_module)) {
            if (!isset($GLOBALS['conf']['consistent_cache_default_class'])) {
              $requirements['panels_content_cache'] = array(
                'severity' => REQUIREMENT_WARNING,
                'title' => 'Panels Content Cache',
                'value' => $t('Installing the <a href="@url">Cache Consistency</a> module is recommended.', array(
                  '@url' => 'https://www.drupal.org/project/cache_consistent',
                )),
                'description' => $t('There is <a href="@bug">a bug in Drupal core</a> that results in race conditions when not using the database as the primary cache. To work around this issue, it is recommended to install the <a href="@cc">Cache Consistency</a> module until the core bug is fixed.', array(
                  '@bug' => 'https://www.drupal.org/node/1679344',
                  '@cc' => 'https://www.drupal.org/project/cache_consistent',
                )),
              );
              continue;
            }
          }
        }
      }
    }
  }
  return $requirements;
}