diff --git a/advagg.install b/advagg.install index a78af2e..08d622e 100644 --- a/advagg.install +++ b/advagg.install @@ -379,192 +379,194 @@ function advagg_requirements($phase) { ); } } + // Check to see if any incompatible modules are installed. + if (module_exists('agrcache')) { + $requirements['advagg_module_agrcache'] = array( + 'title' => $t('Adv CSS/JS Agg - Aggregate cache module'), + 'severity' => REQUIREMENT_ERROR, + 'value' => $phase == 'install' ? FALSE : $t('The Aggregate cache module is incompatible with AdvAgg.'), + 'description' => $t('You need to uninstall the agrcache module or uninstall AdvAgg.'), + ); + } + if (module_exists('bundle_aggregation')) { + $requirements['advagg_module_bundle_aggregation'] = array( + 'title' => $t('Adv CSS/JS Agg - Bundle aggregation module'), + 'severity' => REQUIREMENT_ERROR, + 'value' => $phase == 'install' ? FALSE : $t('The Bundle aggregation module is incompatible with AdvAgg.'), + 'description' => $t('You need to uninstall the bundle_aggregation module or uninstall AdvAgg.'), + ); + } + if (module_exists('core_library')) { + $requirements['advagg_module_core_library'] = array( + 'title' => $t('Adv CSS/JS Agg - Core Library module'), + 'severity' => REQUIREMENT_ERROR, + 'value' => $phase == 'install' ? FALSE : $t('The Core Library module is incompatible with AdvAgg.'), + 'description' => $t('You need to uninstall the core_library module or uninstall AdvAgg.'), + ); + } + + // If not at runtime, return here. + if ($phase != 'runtime') { + return $requirements; + } // Do the following checks only at runtime. - if ($phase == 'runtime') { - list($css_path, $js_path) = advagg_get_root_files_dir(); - $config_path = advagg_admin_config_root_path(); - - // Make sure directories are writable. - if (!file_prepare_directory($css_path[0], FILE_CREATE_DIRECTORY)) { - $requirements['advagg_css_path'] = array( - 'title' => $t('Adv CSS/JS Agg - CSS Path'), - 'severity' => REQUIREMENT_ERROR, - 'value' => $t('CSS directory is not created or writable.'), - 'description' => $t('%path is not setup correctly.', array('%path' => $css_path)), - ); - } - if (!file_prepare_directory($js_path[0], FILE_CREATE_DIRECTORY)) { - $requirements['advagg_js_path'] = array( - 'title' => $t('Adv CSS/JS Agg - JS Path'), - 'severity' => REQUIREMENT_ERROR, - 'value' => $t('JS directory is not created or writable.'), - 'description' => $t('%path is not setup correctly.', array('%path' => $js_path)), - ); - } + list($css_path, $js_path) = advagg_get_root_files_dir(); + $config_path = advagg_admin_config_root_path(); + + // Make sure directories are writable. + if (!file_prepare_directory($css_path[0], FILE_CREATE_DIRECTORY)) { + $requirements['advagg_css_path'] = array( + 'title' => $t('Adv CSS/JS Agg - CSS Path'), + 'severity' => REQUIREMENT_ERROR, + 'value' => $t('CSS directory is not created or writable.'), + 'description' => $t('%path is not setup correctly.', array('%path' => $css_path)), + ); + } + if (!file_prepare_directory($js_path[0], FILE_CREATE_DIRECTORY)) { + $requirements['advagg_js_path'] = array( + 'title' => $t('Adv CSS/JS Agg - JS Path'), + 'severity' => REQUIREMENT_ERROR, + 'value' => $t('JS directory is not created or writable.'), + 'description' => $t('%path is not setup correctly.', array('%path' => $js_path)), + ); + } - // Make sure variables are set correctly. - if (!variable_get('preprocess_css', FALSE) || !variable_get('preprocess_js', FALSE)) { - $requirements['advagg_core_off'] = array( - 'title' => $t('Adv CSS/JS Agg - Core Variables'), - 'severity' => REQUIREMENT_ERROR, - 'value' => $t('Cores CSS and/or JS aggregation is disabled.'), - 'description' => $t('"Optimize CSS files" and "Optimize JavaScript files" on the performance page should be enabled.', array('@performance' => url('admin/config/development/performance'))), - ); - } - if (variable_get('advagg_enabled', ADVAGG_ENABLED) == FALSE) { - $requirements['advagg_not_on'] = array( - 'title' => $t('Adv CSS/JS Agg - Enabled'), - 'severity' => REQUIREMENT_WARNING, - 'value' => $t('Advanced CSS/JS aggregation is disabled.'), - 'description' => $t('Go to the Advanced CSS/JS aggregation settings page and enable it.', array('@settings' => url($config_path . '/advagg'))), - ); - } + // Make sure variables are set correctly. + if (!variable_get('preprocess_css', FALSE) || !variable_get('preprocess_js', FALSE)) { + $requirements['advagg_core_off'] = array( + 'title' => $t('Adv CSS/JS Agg - Core Variables'), + 'severity' => REQUIREMENT_ERROR, + 'value' => $t('Cores CSS and/or JS aggregation is disabled.'), + 'description' => $t('"Optimize CSS files" and "Optimize JavaScript files" on the performance page should be enabled.', array('@performance' => url('admin/config/development/performance'))), + ); + } + if (variable_get('advagg_enabled', ADVAGG_ENABLED) == FALSE) { + $requirements['advagg_not_on'] = array( + 'title' => $t('Adv CSS/JS Agg - Enabled'), + 'severity' => REQUIREMENT_WARNING, + 'value' => $t('Advanced CSS/JS aggregation is disabled.'), + 'description' => $t('Go to the Advanced CSS/JS aggregation settings page and enable it.', array('@settings' => url($config_path . '/advagg'))), + ); + } - // Check that the menu router handler is working. - $item = menu_get_item($css_path[1] . '/test.css'); - if (empty($item['page_callback']) || strpos($item['page_callback'], 'advagg') === FALSE) { - $item = str_replace(' ', '    ', nl2br(htmlentities(print_r($item, TRUE)))); - $requirements['advagg_async_generation_menu_issue_css'] = array( - 'title' => $t('Adv CSS/JS Agg - Async Mode'), - 'severity' => REQUIREMENT_WARNING, - 'value' => $t('Flush your caches.'), - 'description' => $t('You need to flush your menu cache. This can be done at the top of the performance page. If this does not fix the issue copy this info below when opening up an issue for advagg:
!info', array( - '@performance' => url('admin/config/development/performance'), - '!info' => $item, - )), - ); - } - $item = menu_get_item($js_path[1] . '/test.js'); - if (empty($item['page_callback']) || strpos($item['page_callback'], 'advagg') === FALSE) { - $item = str_replace(' ', '    ', nl2br(htmlentities(print_r($item, TRUE)))); - $requirements['advagg_async_generation_menu_issue_js'] = array( - 'title' => $t('Adv CSS/JS Agg - Async Mode'), - 'severity' => REQUIREMENT_WARNING, - 'value' => $t('Flush your caches.'), - 'description' => $t('You need to flush your menu cache. This can be done near the top of the performance page under Clear cache. If this does not fix the issue copy this info below when opening up an issue for advagg:
!info', array( - '@performance' => url('admin/config/development/performance'), - '!info' => $item, - )), - ); - } + // Check that the menu router handler is working. + $item = menu_get_item($css_path[1] . '/test.css'); + if (empty($item['page_callback']) || strpos($item['page_callback'], 'advagg') === FALSE) { + $item = str_replace(' ', '    ', nl2br(htmlentities(print_r($item, TRUE)))); + $requirements['advagg_async_generation_menu_issue_css'] = array( + 'title' => $t('Adv CSS/JS Agg - Async Mode'), + 'severity' => REQUIREMENT_WARNING, + 'value' => $t('Flush your caches.'), + 'description' => $t('You need to flush your menu cache. This can be done at the top of the performance page. If this does not fix the issue copy this info below when opening up an issue for advagg:
!info', array( + '@performance' => url('admin/config/development/performance'), + '!info' => $item, + )), + ); + } + $item = menu_get_item($js_path[1] . '/test.js'); + if (empty($item['page_callback']) || strpos($item['page_callback'], 'advagg') === FALSE) { + $item = str_replace(' ', '    ', nl2br(htmlentities(print_r($item, TRUE)))); + $requirements['advagg_async_generation_menu_issue_js'] = array( + 'title' => $t('Adv CSS/JS Agg - Async Mode'), + 'severity' => REQUIREMENT_WARNING, + 'value' => $t('Flush your caches.'), + 'description' => $t('You need to flush your menu cache. This can be done near the top of the performance page under Clear cache. If this does not fix the issue copy this info below when opening up an issue for advagg:
!info', array( + '@performance' => url('admin/config/development/performance'), + '!info' => $item, + )), + ); + } - // Check to see if any incompatible modules are installed. - if (module_exists('agrcache')) { - $requirements['advagg_module_agrcache'] = array( - 'title' => $t('Adv CSS/JS Agg - Aggregate cache module'), - 'severity' => REQUIREMENT_ERROR, - 'value' => $t('The Aggregate cache module is incompatible with AdvAgg.'), - 'description' => $t('You need to uninstall the agrcache module or uninstall AdvAgg.'), - ); - } - if (module_exists('bundle_aggregation')) { - $requirements['advagg_module_bundle_aggregation'] = array( - 'title' => $t('Adv CSS/JS Agg - Bundle aggregation module'), + // Make sure some modules have the correct patches installed. + if (module_exists('css_emimage')) { + $file_path = drupal_get_path('module', 'css_emimage'); + if (!file_exists($file_path . '/css_emimage.advagg.inc')) { + $requirements['advagg_module_css_emimage_patch'] = array( + 'title' => $t('Adv CSS/JS Agg - CSS Embedded Images module'), 'severity' => REQUIREMENT_ERROR, - 'value' => $t('The Bundle aggregation module is incompatible with AdvAgg.'), - 'description' => $t('You need to uninstall the bundle_aggregation module or uninstall AdvAgg.'), + 'value' => $t('The CSS Embedded Images module needs to be updated.'), + 'description' => $t('CSS Embedded Images needs to be upgraded to version 1.3 or higher, the currently installed version is incompatible with AdvAgg.', array('@link' => 'http://drupal.org/project/css_emimage')), ); } - if (module_exists('core_library')) { - $requirements['advagg_module_core_library'] = array( - 'title' => $t('Adv CSS/JS Agg - Core Library module'), - 'severity' => REQUIREMENT_ERROR, - 'value' => $t('The Core Library module is incompatible with AdvAgg.'), - 'description' => $t('You need to uninstall the core_library module or uninstall AdvAgg.'), + } + if (module_exists('cdn')) { + $file_path = drupal_get_path('module', 'cdn'); + if (!file_exists($file_path . '/cdn.advagg.inc')) { + $requirements['advagg_module_cdn_patch'] = array( + 'title' => $t('Adv CSS/JS Agg - CDN module'), + 'severity' => REQUIREMENT_WARNING, + 'value' => $t('The CDN module needs a patch to be fully compatible with AdvAgg.'), + 'description' => $t('You should install the latest patch in this issue.', array('@link' => 'http://drupal.org/node/1942230')), ); } - - // Make sure some modules have the correct patches installed. - if (module_exists('css_emimage')) { - $file_path = drupal_get_path('module', 'css_emimage'); - if (!file_exists($file_path . '/css_emimage.advagg.inc')) { - $requirements['advagg_module_css_emimage_patch'] = array( - 'title' => $t('Adv CSS/JS Agg - CSS Embedded Images module'), - 'severity' => REQUIREMENT_ERROR, - 'value' => $t('The CSS Embedded Images module needs to be updated.'), - 'description' => $t('CSS Embedded Images needs to be upgraded to version 1.3 or higher, the currently installed version is incompatible with AdvAgg.', array('@link' => 'http://drupal.org/project/css_emimage')), - ); - } - } - if (module_exists('cdn')) { - $file_path = drupal_get_path('module', 'cdn'); - if (!file_exists($file_path . '/cdn.advagg.inc')) { + else { + module_load_include('inc', 'cdn', 'cdn.advagg'); + if (!function_exists('cdn_advagg_context_alter')) { $requirements['advagg_module_cdn_patch'] = array( 'title' => $t('Adv CSS/JS Agg - CDN module'), - 'severity' => REQUIREMENT_WARNING, - 'value' => $t('The CDN module needs a patch to be fully compatible with AdvAgg.'), - 'description' => $t('You should install the latest patch in this issue.', array('@link' => 'http://drupal.org/node/1942230')), - ); - } - else { - module_load_include('inc', 'cdn', 'cdn.advagg'); - if (!function_exists('cdn_advagg_context_alter')) { - $requirements['advagg_module_cdn_patch'] = array( - 'title' => $t('Adv CSS/JS Agg - CDN module'), - 'severity' => REQUIREMENT_ERROR, - 'value' => $t('The CDN module needs to use the latest patch to be compatible with AdvAgg.'), - 'description' => $t('You need to install the latest patch in this issue.', array('@link' => 'http://drupal.org/node/1942230')), - ); - } - } - } - if (module_exists('labjs')) { - if (!function_exists('labjs_advagg_modify_js_pre_render_alter')) { - $requirements['advagg_module_labjs_patch'] = array( - 'title' => $t('Adv CSS/JS Agg - LAB.js module'), 'severity' => REQUIREMENT_ERROR, - 'value' => $t('The LAB.js module needs a patch to be compatible with AdvAgg.'), - 'description' => $t('You need to install the latest patch in this issue.', array('@link' => 'http://drupal.org/node/1977122')), + 'value' => $t('The CDN module needs to use the latest patch to be compatible with AdvAgg.'), + 'description' => $t('You need to install the latest patch in this issue.', array('@link' => 'http://drupal.org/node/1942230')), ); } } + } + if (module_exists('labjs')) { + if (!function_exists('labjs_advagg_modify_js_pre_render_alter')) { + $requirements['advagg_module_labjs_patch'] = array( + 'title' => $t('Adv CSS/JS Agg - LAB.js module'), + 'severity' => REQUIREMENT_ERROR, + 'value' => $t('The LAB.js module needs a patch to be compatible with AdvAgg.'), + 'description' => $t('You need to install the latest patch in this issue.', array('@link' => 'http://drupal.org/node/1977122')), + ); + } + } - // Check that https is correct. - if ( empty($GLOBALS['is_https']) && - ( (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') - || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') - || (isset($_SERVER['HTTP_HTTPS']) && $_SERVER['HTTP_HTTPS'] == 'on') - ) - ) { - $requirements['advagg_is_https_check'] = array( - 'title' => $t('Adv CSS/JS Agg - HTTPS'), - 'severity' => REQUIREMENT_WARNING, - 'value' => $t('The core global $is_https is not TRUE.'), - 'description' => $t('You need to add in this logic near the top your settings.php file:
@code
', array( - '@code' => 'if ( (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") - || (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") - || (isset($_SERVER["HTTP_HTTPS"]) && $_SERVER["HTTP_HTTPS"] == "on") - ) { - $_SERVER["HTTPS"] = "on"; + // Check that https is correct. + if ( empty($GLOBALS['is_https']) && + ( (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') + || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') + || (isset($_SERVER['HTTP_HTTPS']) && $_SERVER['HTTP_HTTPS'] == 'on') + ) + ) { + $requirements['advagg_is_https_check'] = array( + 'title' => $t('Adv CSS/JS Agg - HTTPS'), + 'severity' => REQUIREMENT_WARNING, + 'value' => $t('The core global $is_https is not TRUE.'), + 'description' => $t('You need to add in this logic near the top your settings.php file:
@code
', array( + '@code' => 'if ( (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") +|| (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") +|| (isset($_SERVER["HTTP_HTTPS"]) && $_SERVER["HTTP_HTTPS"] == "on") + ) { +$_SERVER["HTTPS"] = "on"; }'))); - } + } - // Make sure $base_url is correct. - if (!empty($GLOBALS['is_https']) && strpos($GLOBALS['base_url'], 'https://') !== 0) { - $requirements['advagg_is_https_check'] = array( - 'title' => $t('Adv CSS/JS Agg - HTTPS'), - 'severity' => REQUIREMENT_WARNING, - 'value' => $t('The core global $base_url\'s scheme is incorrect.'), - 'description' => $t('You need to add in this logic near the bottom of your settings.php file:
@code
', array( - '@code' => 'if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on" && isset($base_url)) { - $base_url = str_replace("http://", "https://", $base_url); + // Make sure $base_url is correct. + if (!empty($GLOBALS['is_https']) && strpos($GLOBALS['base_url'], 'https://') !== 0) { + $requirements['advagg_is_https_check'] = array( + 'title' => $t('Adv CSS/JS Agg - HTTPS'), + 'severity' => REQUIREMENT_WARNING, + 'value' => $t('The core global $base_url\'s scheme is incorrect.'), + 'description' => $t('You need to add in this logic near the bottom of your settings.php file:
@code
', array( + '@code' => 'if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on" && isset($base_url)) { +$base_url = str_replace("http://", "https://", $base_url); } '))); - } + } - // Make sure http requests will work correctly. - advagg_install_check_via_http($requirements); + // Make sure http requests will work correctly. + advagg_install_check_via_http($requirements); - // If all requirements have been meet, state advagg should be working. - if (empty($requirements)) { - $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.'), - ); - } + // If all requirements have been meet, state advagg should be working. + if (empty($requirements)) { + $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.'), + ); } return $requirements;