function _acquia_purge_diagnostics_inv_domains in Acquia Purge 7
Invalidated domains.
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:
- 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
- ACQUIA_PURGE_SEVLEVEL_OK
- ACQUIA_PURGE_SEVLEVEL_WARNING
- ACQUIA_PURGE_SEVLEVEL_ERROR <-- blocks Acquia Purge from executing!
1 string reference to '_acquia_purge_diagnostics_inv_domains'
File
- ./
acquia_purge.diagnostics.inc, line 481 - Diagnostic self-tests and reports that aim to prevent runtime misery.
Code
function _acquia_purge_diagnostics_inv_domains($t, $service) {
$allriskmode = _acquia_purge_variable('acquia_purge_allriskmode');
$hosting_info = $service
->hostingInfo();
$domains_link = drupal_get_path('module', 'acquia_purge') . '/DOMAINS.md';
$domains_link = url($domains_link);
$domains = $hosting_info
->getDomains();
$domains_c = count($domains);
$test = array(
'value' => implode(', ', $domains),
'value' => $t('@mode: @domains', array(
'@domains' => implode(' ', $domains),
'@mode' => $hosting_info
->areDomainsHardcoded() ? $t('Manual') : $t('Automatic'),
)),
'title' => $t('Invalidated domains'),
'description' => $t('The domains for which content gets cleared from your' . ' load balancers. Every domain name multiplies the 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,
)),
);
// One cannot have wildcards in domain names, test for this.
$wildcard_domains_found = FALSE;
foreach ($domains as $domain) {
if (strpos($domain, '*') !== FALSE) {
$wildcard_domains_found = $domain;
break;
}
}
// Evaluate domain names configuration and kick off warnings or even a full
// block when the situation asks for it.
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 ($wildcard_domains_found) {
$test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
$test['description'] = $t('The domain "@baddomain" has a asterisk in it,' . ' which implies that its subdomains require clearing. However, this is' . ' unfortunately not supported by Acquia Cloud and therefore will lead' . ' to purge failure. Please remove this domain from your configuration.', array(
'@baddomain' => $wildcard_domains_found,
));
}
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;
unset($test['description']);
}
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 clearing 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,
));
}
elseif ($allriskmode) {
$test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
$test['description'] = $t('Because you have @no domain names there is a' . ' <b>high risk</b> that clearing 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 clearing 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;
}