View Issue Details

IDProjectCategoryView StatusLast Update
0028832mantisbtapi soappublic2021-07-06 14:52
Reportersean.gordon Assigned Todregad  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionno change required 
Product Version2.25.2 
Summary0028832: Unknown filetype causes crash in SOAP
Description

We use a testlink integration and it stopped working upon upgrade to 2.25.2 I found that the apache log was filled with errors such as:

[Mon Jun 21 17:09:33.649879 2021] [php7:notice] [pid 22170] [client 10.192.3.xxx:24334] [mantisconnect.php] Error Type: APPLICATION WARNING #300,\nError Description: String "unknown_file_extension" not found.\nStack Trace:\nlang_api.php L307 trigger_error(<string>'300', <integer>512)\nfile_api.php L346 lang_get(<string>'unknown_file_extension')\nfile_api.php L498 file_get_icon_url(<string>'restore_session.18')\nmc_issue_api.php L510 file_get_visible_attachments(<integer>7803)\nmc_issue_api.php L1698 mci_issue_get_attachments(<integer>7803, <integer>0)\nmc_issue_api.php L86 mci_issue_data_as_array(<Object><BugData> ( [attachment_count] => NULL, [bugnotes_count] => NULL, [bug_text_id] => '7803' ), <integer>44, <string>'english')\nUnknownFile L? mc_issue_get(<string>'testlink', <string>'REDACTED', <integer>7803)\nmantisconnect.php L89 handle()\n
[Mon Jun 21 17:09:33.726040 2021] [php7:notice] [pid 22076] [client 10.192.3.xxx:24336] [mantisconnect.php] Error Type: APPLICATION WARNING #300,\nError Description: String "unknown_file_extension" not found.\nStack Trace:\nlang_api.php L307 trigger_error(<string>'300', <integer>512)\nfile_api.php L346 lang_get(<string>'unknown_file_extension')\nfile_api.php L498 file_get_icon_url(<string>'restore_session.20')\nmc_issue_api.php L510 file_get_visible_attachments(<integer>7813)\nmc_issue_api.php L1698 mci_issue_get_attachments(<integer>7813, <integer>0)\nmc_issue_api.php L86 mci_issue_data_as_array(<Object><BugData> ( [attachment_count] => NULL, [bugnotes_count] => NULL, [bug_text_id] => '7813' ), <integer>44, <string>'english')\nUnknownFile L? mc_issue_get(<string>'testlink', <string>'REDACTED', <integer>7813)\nmantisconnect.php L89 handle()\n
[Mon Jun 21 17:09:33.798702 2021] [php7:notice] [pid 21349] [client 10.192.3.xxx:24350] [mantisconnect.php] Error Type: APPLICATION WARNING #300,\nError Description: String "unknown_file_extension" not found.\nStack Trace:\nlang_api.php L307 trigger_error(<string>'300', <integer>512)\nfile_api.php L346 lang_get(<string>'unknown_file_extension')\nfile_api.php L498 file_get_icon_url(<string>'joblog.55')\nmc_issue_api.php L510 file_get_visible_attachments(<integer>7824)\nmc_issue_api.php L1698 mci_issue_get_attachments(<integer>7824, <integer>0)\nmc_issue_api.php L86 mci_issue_data_as_array(<Object><BugData> ( [attachment_count] => NULL, [bugnotes_count] => NULL, [bug_text_id] => '7824' ), <integer>44, <string>'english')\nUnknownFile L? mc_issue_get(<string>'testlink', <string>'REDACTED', <integer>7824)\nmantisconnect.php L89 handle()\n
[Mon Jun 21 17:09:34.543093 2021] [php7:notice] [pid 21909] [client 10.192.3.xxx:24351] [mantisconnect.php] Error Type: APPLICATION WARNING #300,\nError Description: String "unknown_file_extension" not found.\nStack Trace:\nlang_api.php L307 trigger_error(<string>'300', <integer>512)\nfile_api.php L346 lang_get(<string>'unknown_file_extension')\nfile_api.php L498 file_get_icon_url(<string>'m365-debug-0.err')\nmc_issue_api.php L510 file_get_visible_attachments(<integer>7814)\nmc_issue_api.php L1698 mci_issue_get_attachments(<integer>7814, <integer>0)\nmc_issue_api.php L86 mci_issue_data_as_array(<Object><BugData> ( [attachment_count] => NULL, [bugnotes_count] => NULL, [bug_text_id] => '7814' ), <integer>44, <string>'english')\nUnknownFile L? mc_issue_get(<string>'testlink', <string>'REDACTED', <integer>7814)\nmantisconnect.php L89 handle()\n

It is easy to fix. I simply had to go to to core/file_api.php and edit the function:

function file_get_icon_url( $p_display_filename ) {
        $t_file_type_icons = config_get_global( 'file_type_icons' );

        $t_ext = mb_strtolower( pathinfo( $p_display_filename, PATHINFO_EXTENSION ) );
        if( is_blank( $t_ext ) || !isset( $t_file_type_icons[$t_ext] ) ) {
                $t_ext = '?';
        }

        return array(
                'url' => $t_file_type_icons[$t_ext],
//              'alt' => $t_ext == '?' ? lang_get( 'unknown_file_extension' ) : $t_ext    <------------- Disabled
        );
}

This simple change causes the issue to disappear and the Mantis and testlink marriage to once again be happy.

EDIT (dregad): added markdown formatting)

Steps To Reproduce

Use an unknown file extension when opening an issue with the SOAP API

Additional Information

I think the main issue is that the error unknown_file_extension is not included in the language translations so the error handler crashes.

TagsNo tags attached.

Relationships

related to 0027827 closeddregad Improve pop-up description for file icons 

Activities

dregad

dregad

2021-06-22 11:22

developer   ~0065644

I can't reproduce the error.

  • fresh 2.25.2 install
  • create a test issue with an attachment called 'attach.xxx'
  • Run test script
    <?php
    $s = new SoapClient( 'http://localhost/mantis/api/soap/mantisconnect.php?wsdl' );
    $issue = $s->mc_issue_get( 'administrator', 'root', 1 );
    print_r($issue->attachments);

No errors.
Tracing through SOAP API code, in the foreach loop in mci_issue_get_attachments(), $t_attachment_row['icon'] shows, as expected

Array
(
    [url] => fa-file-o
    [alt] => unknown
)

You need to figure out why the lang_get() call is failing to retrieve the unknown_file_extension string on your system.

sean.gordon

sean.gordon

2021-06-22 16:13

reporter   ~0065646

Last edited: 2021-06-22 16:13

Hi dregad,
yep I found the problem, we have a modified strings*.txt so when I packaged the modified files from the previous version, they overwrote your new additions to strings*.txt hence lang_get() fails to find the translation and crashed out. 100% user error here - thanks for your help - I've mate a note in our internal documentation to check for translation updates on upgrade.

Best wishes,
Sean

ps thanks for the formatting fixes

dregad

dregad

2021-06-23 02:43

developer   ~0065649

Thanks for the feedback.