View Issue Details

IDProjectCategoryView StatusLast Update
0025948mantisbtscriptingpublic2019-08-17 14:37
Reportereconsor_ag Assigned Todregad  
PrioritylowSeveritytrivialReproducibilityN/A
Status closedResolutionno change required 
Product Version2.19.0 
Summary0025948: file_attach_files function from file_api.php not working
Description

Hello everyone,

I recently updated my mantis version from 2.6.0 and I noticed that my custom bugnote fileupload page is not working.

Looking into this I found that the file_process_posted_files_for_bug function was removed and replaced with file_attach_files function.

I edited the script with the new function and when I submitted my form it worked without error but when I looked into the bugnote page there was only a note without the file uploaded. Just to test it I inserted the deprecated function into file_api.php and it worked.

Why is the file_attach_files function not working or am I missing something to make it work?

Steps To Reproduce

create a new page with a form and a upload field and call $t_file_infos = file_attach_files ( $_POST['bug_id'], $f_files );

Additional Information

I am not sure if I set the right details please forgive me if I totally missed the rules.

TagsNo tags attached.

Activities

dregad

dregad

2019-07-30 04:10

developer   ~0062452

As part of the refactoring which took place in 2.11.0 (see MantisBT master 26c869f6 / 0023774) the helper_array_transpose() call was removed from the file_attach_files() function; this is probably why it's no longer working for you.

That being said, the correct way to attach files now would be to rely on the relevant Command (i.e. IssueFileAddCommand or possibly IssueNoteAddCommand); have a look at bugnote_add.php for example usage.

econsor_ag

econsor_ag

2019-07-30 10:33

reporter   ~0062459

Thank you very much @dregad. I really wanted to fix this cleanly.
I used the command, but I had a problem submitting the note in private state with the file-upload but I fixed the problem by executing both commands:

  • 1.: IssueFileAddCommand to upload the file
  • 2.: IssueNoteAddCommand with only the note in private view state

Now it works as I intended:)

dregad

dregad

2019-07-30 11:11

developer   ~0062461

Please note that even if the note is private, attachments are public

econsor_ag

econsor_ag

2019-07-30 11:19

reporter   ~0062462

I did not know that, thank you.

dregad

dregad

2019-07-31 05:20

developer   ~0062467

You might want to read 0025935 and 0009802.