You are here

function apachesolr_attachments_requirements in Apache Solr Attachments 7

Same name and namespace in other branches
  1. 6.3 apachesolr_attachments.install \apachesolr_attachments_requirements()
  2. 6 apachesolr_attachments.install \apachesolr_attachments_requirements()
  3. 6.2 apachesolr_attachments.install \apachesolr_attachments_requirements()

Implements hook_requirements().

File

./apachesolr_attachments.install, line 33
Install, update and uninstall functions for the apachesolr_attachments module.

Code

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

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime') {
    if (variable_get('apachesolr_attachments_extract_using', 'tika') == 'tika') {
      $tmp = tempnam(file_directory_temp(), 'apachesolr_attachments');
      exec(variable_get('apachesolr_attachments_java', 'java') . ' -version > ' . $tmp . ' 2>&1');
      if (!preg_match('/Runtime Environment/', file_get_contents($tmp))) {
        $requirements['apachesolr_attachments_java'] = array(
          'title' => $t('Apache Solr Attachments'),
          'value' => $t('Java executable not found'),
          'description' => $t("Could not execute a java command. You may need to set the path of the correct java executable as the variable 'apachesolr_attachments_java' in settings.php."),
          'severity' => REQUIREMENT_ERROR,
        );
      }
    }
  }
  return $requirements;
}