file_requirements($phase)
Implements hook_requirements().
Display information about getting upload progress bars working.
File
- core/modules/file/file.install, line 65
- Install, update and uninstall functions for File module.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | function file_requirements( $phase ) { $requirements = array (); // Check the server's ability to indicate upload progress. if ( $phase == 'runtime' ) { $description = NULL; $implementation = file_progress_implementation(); $server_software = \Drupal::request()->server->get( 'SERVER_SOFTWARE' ); // Test the web server identity. if (preg_match( "/Nginx/i" , $server_software )) { $is_nginx = TRUE; $is_apache = FALSE; $fastcgi = FALSE; } elseif (preg_match( "/Apache/i" , $server_software )) { $is_nginx = FALSE; $is_apache = TRUE; $fastcgi = strpos ( $server_software , 'mod_fastcgi' ) !== FALSE || strpos ( $server_software , 'mod_fcgi' ) !== FALSE; } else { $is_nginx = FALSE; $is_apache = FALSE; $fastcgi = FALSE; } 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.' ); } elseif (! $implementation && extension_loaded ( 'apcu' )) { $value = t( 'Not enabled' ); $description = t( 'Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.' ); } elseif (! $implementation ) { $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> (preferred) or to install <a href="http://php.net/apcu">APC</a>.' ); } elseif ( $implementation == 'apc' ) { $value = t( 'Enabled (<a href="http://php.net/manual/apcu.configuration.php#ini.apcu.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.' ); } elseif ( $implementation == 'uploadprogress' ) { $value = t( 'Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)' ); } $requirements [ 'file_progress' ] = array ( 'title' => t( 'Upload progress' ), 'value' => $value , 'description' => $description , ); } return $requirements ; } |
Please login to continue.