You are here

function acquia_agent_requirements in Acquia Connector 6.2

Same name and namespace in other branches
  1. 6 acquia_agent/acquia_agent.install \acquia_agent_requirements()
  2. 7.3 acquia_agent/acquia_agent.install \acquia_agent_requirements()
  3. 7 acquia_agent/acquia_agent.install \acquia_agent_requirements()
  4. 7.2 acquia_agent/acquia_agent.install \acquia_agent_requirements()

Implementation of hook_requirements()

File

acquia_agent/acquia_agent.install, line 69

Code

function acquia_agent_requirements($phase) {
  include_once 'acquia_agent.module';
  acquia_agent_load_versions();
  $requirements = array();
  $has_credentials = acquia_agent_has_credentials();
  $is_active = acquia_agent_subscription_is_active();
  $memory_limit = ini_get('memory_limit');
  switch ($phase) {
    case 'runtime':

      // Inform users on subscription status. Either we know they are active,
      // or we know they have credentials but not active (not set up yet) or
      // we have credentials but an inactive subscription (either bad
      // credentials or expired subscription).
      if ($is_active) {
        $requirements['acquia_subscription_status'] = array(
          'title' => t('Acquia subscription status'),
          'severity' => REQUIREMENT_OK,
          'value' => t('Active'),
          'description' => t('You can also <a href="@refresh-status">manually refresh the subscription status</a>.', array(
            '@refresh-status' => url('admin/settings/acquia-agent/refresh-status', array(
              'query' => drupal_get_destination(),
            )),
          )),
        );
      }
      elseif (!$has_credentials) {
        $requirements['acquia_subscription_status'] = array(
          'title' => t('Acquia subscription status'),
          'severity' => REQUIREMENT_WARNING,
          'value' => t('Unknown'),
          'description' => t('You did not complete your signup Acquia subscription signup. You can provide the subscription identifier and the subscription key at the <a href="@settings">Acquia settings</a> page or try to <a href="@refresh-status">manually refresh the subscription status</a>.', array(
            '@settings' => url('admin/settings/acquia-agent'),
            '@refresh-status' => url('admin/settings/acquia-agent/refresh-status', array(
              'query' => drupal_get_destination(),
            )),
          )),
        );
      }
      else {
        $subscription = variable_get('acquia_subscription_data', array(
          'active' => FALSE,
        ));
        $href = isset($subscription['href']) ? $subscription['href'] . '/health' : 'http://acquia.com/network';
        $requirements['acquia_subscription_status'] = array(
          'title' => t('Acquia subscription status'),
          'severity' => REQUIREMENT_WARNING,
          'value' => t('Inactive'),
          'description' => t('Your subscription is expired or you are using an invalid identifier and key pair. You can check the subscription identifier and the subscription key at the <a href="@settings">Acquia settings</a> page. Check <a href="@acquia-network">your Acquia Subscription</a> for further status information.', array(
            '@settings' => url('admin/settings/acquia-agent'),
            '@acquia-network' => $href,
          )),
        );
      }

      // During runtime, we can't override the PHP memory limit provided by
      // Drupal core, so we supplement it with our own warning instead (but
      // only when necessary to do so).
      if (IS_ACQUIA_DRUPAL && $memory_limit && parse_size($memory_limit) < parse_size(ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY)) {
        $description = t('Drupal core requires @drupal_php_memory_limit, but to take advantage of all the features of Acquia Drupal, we recommend @acquia_php_memory_limit (or more).', array(
          '@drupal_php_memory_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT,
          '@acquia_php_memory_limit' => ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY,
        ));

        // Only append our instructions if they don't already have the ones
        // from Drupal core appearing on the screen.
        if (parse_size($memory_limit) >= parse_size(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)) {
          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['acquia_php_memory_limit'] = array(
          'title' => t('PHP memory limit (Acquia Drupal)'),
          'description' => $description,
          'severity' => REQUIREMENT_WARNING,
          'value' => t('@memory_minimum_limit (or more) is recommended', array(
            '@memory_minimum_limit' => ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY,
          )),
        );
      }
      break;
    case 'install':
      $t = get_t();
      if (IS_ACQUIA_DRUPAL && $memory_limit && parse_size($memory_limit) < parse_size(ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY)) {

        // Override the PHP memory limit warning provided by Drupal core.
        $description = $t('Your PHP memory limit is currently set at %current_memory_limit. Increasing this to %memory_minimum_limit (or more) is recommended to help prevent errors in the installation process and later during operation of the site.', array(
          '%current_memory_limit' => $memory_limit,
          '%memory_minimum_limit' => ACQUIA_DRUPAL_MINIMUM_PHP_MEMORY,
        ));
        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['php_memory_limit'] = array(
          'description' => $description,
          'severity' => REQUIREMENT_WARNING,
        );
      }

      // Ensure this module is compatible with the currently installed version of PHP.
      if (version_compare(phpversion(), 5.0) < 0) {
        $requirements['acquia_php_version'] = array(
          'description' => $t('The Acquia Connector modules require a PHP version of at least 5.0.'),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      break;
  }
  return $requirements;
}