You are here

function apachesolr_attachments_requirements in Apache Solr Attachments 6

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

hook_requirements().

File

./apachesolr_attachments.install, line 32

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_attachment_extract_using', 'tika') == 'tika') {
      $temp = tempnam(file_directory_temp(), 'asa');
      $java = variable_get('apachesolr_attachments_java', 'java');
      exec($java . ' -version > ' . $temp . ' 2>&1');
      $stderror = file_get_contents($temp);
      $found = preg_match('/Runtime Environment/', $stderror);
      if (!$found) {
        $requirements['apachesolr_attachments_java'] = array(
          'title' => $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;
}