View Issue Details

IDProjectCategoryView StatusLast Update
0023791mantisbtattachmentspublic2018-02-04 07:01
Reportersbordoni Assigned Toatrol  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version2.10.0 
Summary0023791: Cannot download or view attachments (bis)
Description

Passing from v2.8.x to v2.9.0, I experience the very same problem reported into 0023737.
After few test, I didn’t fix the problem, and I decided to stay with v2.8.x.

I decided to give a new chance to v2.10, … but it seems to have the very same problem.

After few investigations, I discovered that during the previous tests I installed the wrong PHP edition (TS), while IIS_exp + php_wincache need the NTS one.

This resolved almost every related item into the event log, but the problem was still present.

The happy end is that I had to enable php_fileinfo extension to fix it.

Without it, everytime I try to download any MBT uploaded file, the problem occurs logging the following error (into php log file):

[08-Jan-2018 16:06:33 Europe/Rome] PHP Fatal error:
Uncaught Error: Class 'finfo' not found in <blahblahblah>\mantisbt-2.10.0\core\utility_api.php:308
Stack trace:
#0 <blahblahblah>\mantisbt-2.10.0\file_download.php(161): finfo_get_if_available()
0000001 {main}
thrown in <blahblahblah>\mantisbt-2.10.0\core\utility_api.php on line 308

I hope it may help to fix the problem.

Steps To Reproduce

remove php_fileinfo extension and try to download an attached file.

Additional Information

PHP 7.1.13

TagsNo tags attached.
Attached Files

Relationships

duplicate of 0023707 closedatrol Version 2.9.0 broke the Image view/download of attachments 
related to 0023930 closedatrol Make Fileinfo a mandatory PHP extension 

Activities

atrol

atrol

2018-01-08 13:51

developer   ~0058499

The Admin Guide tells to run admin/check/index.php after upgrading.
There you get a warning, to check the fileinfo extension.

sbordoni

sbordoni

2018-01-10 10:37

reporter   ~0058524

I disabled the php extension and I ran the check script in v2.8.1 and v2.10.0.

Both reports contain the following warning:

Fileinfo extension is available for determining file MIME types
Web clients may struggle to download files without knowing the MIME type of each attachment.

Since it's only a warning, I suppose it should not have any critical impact.

According to the logged php error, the difference is that v2.9.x & v2.10.x seems to trigger an exception whenever they call:

finfo_get_if_available()

Then I compared the versions of the utility_api.php...

v2.8.1

function finfo_get_if_available() {
if( class_exists( 'finfo' ) ) {
$t_info_file = config_get( '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 );
    }

    if( $t_finfo ) {
        return $t_finfo;
    }
}

return null;

}

v2.10.0

function finfo_get_if_available() {

$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 );
}

if( $t_finfo ) {
    return $t_finfo;
}

return null;

}

... and I found that the newer one seems to have a regression.
It doesn't test the existence of 'finfo' class anymore.

The following one is a safer function version for the v2.10.x.

function finfo_get_if_available() {

<b>if( class_exists( 'finfo' ) ) {</b>
    $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 );
    }

    if( $t_finfo ) {
        return $t_finfo;
    }
<b>}</b>
return null;

}

I tested it on my system (without the extension), and everything is returned to work fine as usual.

Regards