5 * Install, update and uninstall functions for File module.
9 * Implements hook_schema().
11 function file_schema() {
12 $schema['file_usage'] = [
13 'description' => 'Track where a file is used.',
16 'description' => 'File ID.',
22 'description' => 'The name of the module that is using the file.',
23 'type' => 'varchar_ascii',
24 'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
29 'description' => 'The name of the object type in which the file is used.',
30 'type' => 'varchar_ascii',
36 'description' => 'The primary key of the object using the file.',
37 'type' => 'varchar_ascii',
43 'description' => 'The number of times this file is used by this object.',
50 'primary key' => ['fid', 'type', 'id', 'module'],
52 'type_id' => ['type', 'id'],
53 'fid_count' => ['fid', 'count'],
54 'fid_module' => ['fid', 'module'],
61 * Implements hook_requirements().
63 * Display information about getting upload progress bars working.
65 function file_requirements($phase) {
68 // Check the server's ability to indicate upload progress.
69 if ($phase == 'runtime') {
71 $implementation = file_progress_implementation();
72 $server_software = \Drupal::request()->server->get('SERVER_SOFTWARE');
74 // Test the web server identity.
75 if (preg_match("/Nginx/i", $server_software)) {
80 elseif (preg_match("/Apache/i", $server_software)) {
83 $fastcgi = strpos($server_software, 'mod_fastcgi') !== FALSE || strpos($server_software, 'mod_fcgi') !== FALSE;
91 if (!$is_apache && !$is_nginx) {
92 $value = t('Not enabled');
93 $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.');
96 $value = t('Not enabled');
97 $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.');
99 elseif (!$implementation) {
100 $value = t('Not enabled');
101 $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>.');
103 elseif ($implementation == 'apc') {
104 $value = t('Enabled (<a href="http://php.net/manual/apcu.configuration.php#ini.apcu.rfc1867">APC RFC1867</a>)');
105 $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.');
107 elseif ($implementation == 'uploadprogress') {
108 $value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
110 $requirements['file_progress'] = [
111 'title' => t('Upload progress'),
113 'description' => $description,
117 return $requirements;