You are here

function panopoly_core_requirements in Panopoly Core 7

Implementation of hook_requirements()

Adapted from system_requirements()

File

./panopoly_core.install, line 13
An installation file for Panopoly Core

Code

function panopoly_core_requirements($phase) {

  // Kick us off
  $requirements = array();

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

  // Let's require more memory and force Drupal core to accept it
  $memory_limit = ini_get('memory_limit');
  $panopoly_memory_limit = '196M';
  $requirements['panopoly_core_memory_limit'] = array(
    'title' => $t('PHP memory limit'),
    'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
    'weight' => 0,
  );
  if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size($panopoly_memory_limit)) {
    $description = '';
    if ($phase == 'install') {
      $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array(
        '%memory_minimum_limit' => $panopoly_memory_limit,
      ));
    }
    elseif ($phase == 'update') {
      $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array(
        '%memory_minimum_limit' => $panopoly_memory_limit,
      ));
    }
    elseif ($phase == 'runtime') {
      $description = $t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array(
        '%memory_limit' => $memory_limit,
        '%memory_minimum_limit' => $panopoly_memory_limit,
      ));
    }
    if (!empty($description)) {
      if ($php_ini_path = get_cfg_var('cfg_file_path')) {
        $description .= ' ' . $t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array(
          '%configuration-file' => $php_ini_path,
        ));
      }
      else {
        $description .= ' ' . $t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
      }
      $requirements['panopoly_core_memory_limit']['description'] = $description . ' ' . $t('See the <a href="@url">Drupal requirements</a> for more information.', array(
        '@url' => 'http://drupal.org/requirements',
      ));
      $requirements['panopoly_core_memory_limit']['severity'] = REQUIREMENT_WARNING;
    }
  }
  return $requirements;
}