You are here

function advagg_js_compress_requirements in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg_js_compress/advagg_js_compress.install \advagg_js_compress_requirements()
  2. 7.2 advagg_js_compress/advagg_js_compress.install \advagg_js_compress_requirements()

Implements hook_requirements().

1 string reference to 'advagg_js_compress_requirements'
advagg_js_compress_enable in advagg_js_compress/advagg_js_compress.install
Implements hook_enable().

File

advagg_js_compress/advagg_js_compress.install, line 66
Handles AdvAgg JS compress installation and upgrade tasks.

Code

function advagg_js_compress_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();

  // Report Drupal version
  if ($phase == 'runtime') {
    $compressible = advagg_js_compress_check_callback();
    $advagg_js_compress_callback = variable_get('advagg_js_compress_callback', ADVAGG_JS_COMPRESS_CALLBACK);
    if (is_array($compressible)) {
      $requirements['advagg_js_compress_callback'] = array(
        'title' => $t('AdvAgg JS Compress - Callback'),
        'severity' => REQUIREMENT_WARNING,
        'value' => $t('The callback for testing if a JS file is compressible is not working.'),
        'description' => $t('As a result if jsmin+ encounters a file that it cannot compress, it will kill that PHP process.'),
      );
      if ($advagg_js_compress_callback != FALSE) {
        variable_set('advagg_js_compress_callback', FALSE);
      }
    }
    else {
      $requirements['advagg_js_compress_callback'] = array(
        'title' => $t('AdvAgg JS Compress - Callback'),
        'severity' => REQUIREMENT_OK,
        'value' => $t('The callback is working correctly.'),
      );
      if ($advagg_js_compress_callback == FALSE) {
        variable_set('advagg_js_compress_callback', TRUE);
      }
    }

    // Test the 'memory_limit' PHP configuration directive
    $memory_limit = ini_get('memory_limit');
    $compressor = variable_get('advagg_js_compressor', ADVAGG_JS_COMPRESSOR);

    // If $memory_limit contains a value of -1, the PHP runtime
    // doesn't impose a limit on memory used by PHP scripts
    if ($compressor == 0 && $memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size('96M')) {
      $requirements['advagg_js_compress_memory_limit'] = array(
        'title' => $t('AdvAgg JS Compress - Memory Limit'),
        'value' => $memory_limit,
        'severity' => REQUIREMENT_WARNING,
        'description' => $t('It is highly recommended that you set your PHP memory_limit at least 96M if you are going to use JSMin+.'),
      );
    }
  }
  return $requirements;
}