Skip to content
Snippets Groups Projects
file.install 3.36 KiB
Newer Older
<?php

/**
 * @file
 * Install, update and uninstall functions for File module.
 */

/**
 * Implements hook_schema().
 */
function file_schema() {
    'description' => 'Track where a file is used.',
        'description' => 'File ID.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The name of the module that is using the file.',
        'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
        'description' => 'The name of the object type in which the file is used.',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The primary key of the object using the file.',
        'description' => 'The number of times this file is used by this object.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => ['fid', 'type', 'id', 'module'],
    'indexes' => [
      'type_id' => ['type', 'id'],
      'fid_count' => ['fid', 'count'],
      'fid_module' => ['fid', 'module'],
    ],
  ];
 *
 * Display information about getting upload progress bars working.
 */
function file_requirements($phase) {
  if ($phase != 'runtime') {
    return $requirements;
  }

  $server_software = \Drupal::request()->server->get('SERVER_SOFTWARE', '');
  // Get the web server identity.
  $is_nginx = preg_match("/Nginx/i", $server_software);
  $is_apache = preg_match("/Apache/i", $server_software);
  $fastcgi = $is_apache && ((str_contains($server_software, 'mod_fastcgi') || str_contains($server_software, 'mod_fcgi')));

  // Check the uploadprogress extension is loaded.
  if (extension_loaded('uploadprogress')) {
    $value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
    $description = NULL;
  }
  else {
    $value = t('Not enabled');
    $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a>.');
  }
  // Adjust the requirement depending on what the server supports.
  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.');
  }
  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 or PHP-FPM and not as FastCGI.');
  $requirements['file_progress'] = [
    'title' => t('Upload progress'),
    'value' => $value,
    'description' => $description,
  ];

 * Implements hook_update_last_removed().
function file_update_last_removed(): int {