Same name in other branches
- 5.0.x advagg.install \advagg_requirements()
- 6.0.x advagg.install \advagg_requirements()
- 7.x-1.x advagg.install \advagg_requirements()
- 8.x-2.x advagg.install \advagg_requirements()
- 8.x-3.x advagg.install \advagg_requirements()
- 8.x-4.x advagg.install \advagg_requirements()
Implements hook_requirements().
Fichier
-
./
advagg.install, line 1259
Code
function advagg_requirements($phase) {
$t = get_t();
$requirements = advagg_install_fast_checks($phase);
// If not at runtime, return here.
if ($phase !== 'runtime') {
return $requirements;
}
// Make sure outbound http requests will work.
$request = drupal_http_request('https://www.google.com/robots.txt', array(
'timeout' => 8,
));
if (empty($request->data) || $request->code != 200) {
$requirements['advagg_drupal_http_request_failure'] = array(
'title' => $t('Adv CSS/JS Agg - drupal_http_request test'),
'severity' => REQUIREMENT_WARNING,
'value' => $t('An external request for https://www.google.com/robots.txt could not be fulfilled.'),
'description' => $t('If drupal_http_request does not work, the tests that AdvAgg performs may not be accurate.'),
);
}
// Make sure http requests to advagg will work.
advagg_install_check_via_http($requirements);
// Check that file writes happen without any errors.
if (empty($requirements)) {
module_load_include("missing.inc", "advagg");
$current_hash = advagg_get_current_hooks_hash();
$aggregate_settings = advagg_get_hash_settings($current_hash);
$types = array(
'css',
'js',
);
foreach ($types as $type) {
$filename = $type . ADVAGG_SPACE . 'test_write' . REQUEST_TIME . '.' . $type;
$files = array(
'misc/farbtastic/farbtastic.' . $type => array(),
);
list($files_to_save, $errors) = advagg_save_aggregate($filename, $files, $type, $aggregate_settings);
foreach ($files_to_save as $uri => $data) {
@unlink($uri);
}
if (!empty($errors)) {
$requirements['advagg_file_write_error_' . $type] = array(
'title' => $t('Adv CSS/JS Agg - File Write'),
'severity' => REQUIREMENT_WARNING,
'value' => $t('File write had some issues with %type files.', array(
'%type' => $type,
)),
'description' => $t('Most likely there is an issue with file and/or directory premissions. Error: @error', array(
'@error' => print_r($errors, TRUE),
)),
);
}
}
}
// If all requirements have been met, state advagg should be working.
if (empty($requirements)) {
$description = '';
if (variable_get('advagg_cache_level', ADVAGG_CACHE_LEVEL) < 0) {
$description .= ' ' . $t('Currently running in development mode.');
}
if (variable_get('advagg_cache_level', ADVAGG_CACHE_LEVEL) < 5) {
$aggressive_cache_conflicts = advagg_aggressive_cache_conflicts();
if (empty($aggressive_cache_conflicts)) {
$description .= ' ' . $t('It appears that there are no incompatible modules, so you should be able to safely use the Aggressive cache. To adjust this setting, go to the <a href="@config">AdvAgg: configuration page</a> and under "AdvAgg Cache Settings" select Aggressive and then save.', array(
'@config' => url('admin/config/development/performance/advagg', array(
'fragment' => 'edit-advagg-cache-level',
)),
));
}
}
$requirements['advagg_ok'] = array(
'title' => $t('Adv CSS/JS Agg'),
'severity' => REQUIREMENT_OK,
'value' => $t('OK'),
'description' => $t('Advanced CSS/JS Aggregator should be working correctly.') . ' ' . $description,
);
}
return $requirements;
}