You are here

function _acquia_purge_diagnostics_expire_module in Acquia Purge 7

Expire module.

Parameters

string $t: Name of the t() function to call.

AcquiaPurgeService $service: The Acquia Purge service.

Return value

array Associative array with the following elements:

1 string reference to '_acquia_purge_diagnostics_expire_module'
acquia_purge_acquia_purge_diagnostics in ./acquia_purge.module
Implements hook_acquia_purge_diagnostics().

File

./acquia_purge.diagnostics.inc, line 664
Diagnostic self-tests and reports that aim to prevent runtime misery.

Code

function _acquia_purge_diagnostics_expire_module($t, $service) {
  $test = array(
    'title' => $t('Expire module'),
  );

  // If expire is not installed, Acquia Purge can still work as API.
  if (!module_exists('expire')) {
    $test['value'] = $t('Not installed!');
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('The expire module is not present, which only' . ' makes sense if you want to use Acquia Purge as pure API (and have' . ' removed expire from acquia_purge.info). If you want your content to' . ' be cleared when is changing, enable it back on again.');
    return $test;
  }

  // Read out Expire's 'expire_status' variable.
  $statuses = array(
    EXPIRE_STATUS_ENABLED_EXTERNAL => $t('External expiration'),
    EXPIRE_STATUS_ENABLED_INTERNAL => $t('Internal expiration'),
    EXPIRE_STATUS_DISABLED => $t('Disabled'),
    'n/a' => $t('unknown'),
  );
  $status = (int) variable_get('expire_status', EXPIRE_STATUS_DISABLED);
  $status_t = isset($statuses[$status]) ? $statuses[$status] : $statuses['n/a'];

  // Test Expire's 'expire_include_base_url' variable, which should be FALSE.
  if (variable_get('expire_include_base_url', EXPIRE_INCLUDE_BASE_URL)) {
    $test['value'] = $t('Include base URL in expires');
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['description'] = $t("This setting must be disabled as Acquia Purge" . ' cannot process full URLs but operates on paths instead.');
  }
  elseif (variable_get('expire_debug', EXPIRE_DEBUG_DISABLED)) {
    $test['value'] = $t('Debugging enabled');
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['description'] = $t("Expire's debugging is enabled which is highly" . ' discouraged! Acquia Purge also logs very heavily and together with' . ' Expire debugging, this could break down your site!');
  }
  elseif ($status === EXPIRE_STATUS_ENABLED_EXTERNAL) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_OK;
    $test['value'] = $t('Delegates URLs to Acquia Purge');
  }
  else {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['value'] = $t('Status: @status', array(
      '@status' => $status_t,
    ));
    $test['description'] = $t('The Expire module operates in the "@status" mode' . ', this means that Expire will not delegate URLs to Acquia Purge when' . ' you are updating content. Change it to "External expiration".', array(
      '@status' => $status_t,
    ));
  }
  return $test;
}