You are here

function _acquia_purge_get_diagnosis_domains in Acquia Purge 6

Test whether the amount of domain names is healthy.

@returns Associative array with the following elements:

  • title: The name of the requirement.
  • value: The current value (e.g., version, time, level, etc).
  • description: The description of the requirement/status.
  • severity: ACQUIA_PURGE_SEVLEVEL_INFO, _OK, _WARNING, _ERROR

Parameters

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

File

./acquia_purge.diagnostics.inc, line 159
Self-test diagnostic test functions for _acquia_purge_get_diagnosis().

Code

function _acquia_purge_get_diagnosis_domains($t) {
  $domains_link = drupal_get_path('module', 'acquia_purge') . '/DOMAINS.txt';
  $domains_link = url($domains_link);
  $domains = _acquia_purge_get_domains();
  $domains_c = count($domains);
  $test = array(
    'value' => implode(', ', $domains),
    'title' => $t('Purged domains'),
    'description' => $t('The domains for which content gets cleared from your' . ' load balancers. Every domain name multiplies the purging work to be' . ' done, it is therefore important to <a href="!link" target="_blank">' . 'specify your domains</a> when the automatically detected list exceeds' . ' 4 domains or when it is incorrect.', array(
      '!link' => $domains_link,
    )),
  );

  // Start evaluating the list of domain names.
  if (!$domains_c) {
    $test['value'] = $t('0 domains detected.');
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['description'] = $t('No domains have been detected which implies that' . ' something is seriously wrong. Pending purges will not be processed.');
  }
  elseif (php_sapi_name() === 'cli' && in_array('default', $domains)) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['description'] = $t('The domain name "default" has been found' . ' indicating that you are running via Drush. Either you will need to' . ' specify your domains or provide --uri for the right site.');
  }
  elseif ($domains_c <= 6) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_OK;
  }
  elseif ($domains_c > 6 && $domains_c <= 8) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('Because you have @no domain names there is a' . ' <b>high risk</b> that purging your site will put stress on your' . ' servers, it is <b>strongly recommended</b> to <a href="!link"' . ' target="_blank">specify your domains</a> to not exceed 6 domains.', array(
      '!link' => $domains_link,
      '@no' => $domains_c,
    ));
  }
  else {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['description'] = $t('Because you have @no domain names there is a' . ' <b>very high risk</b> that purging your site will put stress on your' . ' servers, it is <b>strongly recommended</b> to <a href="!link"' . ' target="_blank">specify your domains</a> to not exceed 6 domains. To' . ' prevent system failure, pending purges will not be processed!', array(
      '!link' => $domains_link,
      '@no' => $domains_c,
    ));
  }
  return $test;
}