You are here

function themekey_page_cache_warning in ThemeKey 7

Same name and namespace in other branches
  1. 6.4 themekey_admin.inc \themekey_page_cache_warning()
  2. 6.3 themekey_admin.inc \themekey_page_cache_warning()
  3. 7.3 themekey_admin.inc \themekey_page_cache_warning()
  4. 7.2 themekey_admin.inc \themekey_page_cache_warning()

Detects if page cache is active and incompatible properties are used in theme switching rule chain

1 call to themekey_page_cache_warning()
theme_themekey_rule_chain_form in ./themekey_admin.inc
Themes themekey_rule_chain_form() and adds drag'n'drop features.

File

./themekey_admin.inc, line 746

Code

function themekey_page_cache_warning($page_cache_support) {
  static $warnings = array();
  if (variable_get('cache', 0)) {
    switch ($page_cache_support) {
      case THEMEKEY_PAGECACHE_UNSUPPORTED:
        if (!isset($warnings[THEMEKEY_PAGECACHE_UNSUPPORTED])) {
          drupal_set_message(filter_xss(t('!page_cache_icon Your site uses !page_caching, but the Theme Switching Rule Chain contains properties that do not support page caching. You have to ensure that any rule using those properties are wrapped by a different rule that excludes anonymous users like "user:uid > 0".', array(
            '!page_caching' => l(t('page caching'), 'admin/config/development/performance'),
            '!page_cache_icon' => theme('themekey_page_cache_icon', array(
              'page_cache_support' => $page_cache_support,
            )),
          )), array(
            'a',
            'img',
          )), 'warning');
          $warnings[THEMEKEY_PAGECACHE_UNSUPPORTED] = TRUE;
        }
        break;
      case THEMEKEY_PAGECACHE_TIMEBASED:
        if (!isset($warnings[THEMEKEY_PAGECACHE_TIMEBASED])) {
          if (variable_get('themekey_cron_page_cache', 1)) {
            drupal_set_message(filter_xss(t('!page_cache_icon Your site uses !page_caching and the Theme Switching Rule Chain contains properties that require your cron to run frequently enough. During the cron run ThemeKey deletes the page cache if necessary depending on your Theme Switching Rules.', array(
              '!page_caching' => l(t('page caching'), 'admin/config/development/performance'),
              '!page_cache_icon' => theme('themekey_page_cache_icon', array(
                'page_cache_support' => $page_cache_support,
              )),
            )), array(
              'a',
              'img',
            )), 'warning');
          }
          else {
            drupal_set_message(filter_xss(t('!page_cache_icon Your site uses !page_caching and the Theme Switching Rule Chain contains properties that require "!cron_page_cache" to be enabled, but it is disabled.', array(
              '!page_caching' => l(t('page caching'), 'admin/config/development/performance'),
              '!cron_page_cache' => l(t('Cron cleans up page cache'), 'admin/config/user-interface/themekey/settings'),
              '!page_cache_icon' => theme('themekey_page_cache_icon', array(
                'page_cache_support' => $page_cache_support,
              )),
            )), array(
              'a',
              'img',
            )), 'error');
          }
          $warnings[THEMEKEY_PAGECACHE_TIMEBASED] = TRUE;
        }
        break;
    }
  }
}