1 file.install file_requirements($phase)

Implements hook_requirements().

Display information about getting upload progress bars working.

File

core/modules/file/file.install, line 229
Install, update and uninstall functions for File module.

Code

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

  if ($phase == 'runtime') {
    // Check the server's ability to indicate upload progress.
    $description = NULL;
    $implementation = file_progress_implementation();
    $server_software = $_SERVER['SERVER_SOFTWARE'];

    // Test the web server identity.
    $is_nginx = backdrop_is_nginx();
    $is_apache = backdrop_is_apache();
    $fastcgi = FALSE;
    if ($is_apache) {
      $fastcgi = strpos($server_software, 'mod_fastcgi') !== FALSE || strpos($server_software, 'mod_fcgi') !== FALSE;
    }

    $description = NULL;
    if (!$is_apache && !$is_nginx) {
      $value = t('Not enabled');
      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires an Apache server running PHP with mod_php or Nginx with PHP-FPM.');
      $severity = REQUIREMENT_INFO;
    }
    elseif ($fastcgi) {
      $value = t('Not enabled');
      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php in Apache or with PHP-FPM and not as FastCGI.');
      $severity = REQUIREMENT_INFO;
    }
    elseif ($implementation == 'apc') {
      $value = t('Enabled (<a href="http://php.net/manual/en/apc.configuration.php#ini.apc.rfc1867">APC RFC1867</a>)');
      $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
      $severity = REQUIREMENT_OK;
    }
    elseif ($implementation == 'uploadprogress') {
      $value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
      $severity = REQUIREMENT_OK;
    }
    elseif ($implementation == 'client') {
      $value = t('Client-side upload progress enabled');
      $severity = REQUIREMENT_OK;
    }
    $requirements['file_progress'] = array(
      'title' => t('Upload progress'),
      'value' => $value,
      'severity' => $severity,
      'description' => $description,
    );

    // Show an error if files need to be classified.
    $file_needs_classification = file_needs_type_classification();
    if ($file_needs_classification) {
      $requirements['file_needs_classification'] = array(
        'title' => t('File Type Classification'),
        'value' => t('File types need to be classified. (<a href="!path">Classify file types</a>).', array('!path' => url('admin/structure/file-types/classify'))),
        'description' => t('This site may not work properly if file types are not classified. Classifying file types may take some time if there are a lot of files without an assigned file type.'),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}