Skip to content

Commit

Permalink
Remove finfo class existence checks
Browse files Browse the repository at this point in the history
As of PHP >= 5.3.0 finfo class is available [1] and enabled by default [2]

[1] http://www.php.net/manual/en/class.finfo.php
[2] http://www.php.net/manual/en/fileinfo.installation.php

Removed all runtime checks but kept them in install/check to have an easy way to find the case where someone disabled the extension.

Issue #23639
  • Loading branch information
atrol committed Nov 16, 2017
1 parent 1187d00 commit 5f6292f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
19 changes: 9 additions & 10 deletions core/file_api.php
Expand Up @@ -972,18 +972,17 @@ function file_get_content( $p_file_id, $p_type = 'bug' ) {

# If finfo is available (always true for PHP >= 5.3.0) we can use it to determine the MIME type of files
$t_finfo_available = false;
if( class_exists( 'finfo' ) ) {
$t_info_file = config_get_global( 'fileinfo_magic_db_file' );

if( is_blank( $t_info_file ) ) {
$t_finfo = new finfo( FILEINFO_MIME );
} else {
$t_finfo = new finfo( FILEINFO_MIME, $t_info_file );
}
$t_info_file = config_get_global( 'fileinfo_magic_db_file' );

if( $t_finfo ) {
$t_finfo_available = true;
}
if( is_blank( $t_info_file ) ) {
$t_finfo = new finfo( FILEINFO_MIME );
} else {
$t_finfo = new finfo( FILEINFO_MIME, $t_info_file );
}

if( $t_finfo ) {
$t_finfo_available = true;
}

$t_content_type = $t_row['file_type'];
Expand Down
19 changes: 9 additions & 10 deletions core/utility_api.php
Expand Up @@ -301,18 +301,17 @@ function get_font_path() {
* @return finfo
*/
function finfo_get_if_available() {
if( class_exists( 'finfo' ) ) {
$t_info_file = config_get_global( 'fileinfo_magic_db_file' );

if( is_blank( $t_info_file ) ) {
$t_finfo = new finfo( FILEINFO_MIME );
} else {
$t_finfo = new finfo( FILEINFO_MIME, $t_info_file );
}
$t_info_file = config_get_global( 'fileinfo_magic_db_file' );

if( $t_finfo ) {
return $t_finfo;
}
if( is_blank( $t_info_file ) ) {
$t_finfo = new finfo( FILEINFO_MIME );
} else {
$t_finfo = new finfo( FILEINFO_MIME, $t_info_file );
}

if( $t_finfo ) {
return $t_finfo;
}

return null;
Expand Down

0 comments on commit 5f6292f

Please sign in to comment.