View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0013415 | mantisbt | attachments | public | 2011-10-17 10:53 | 2014-09-23 18:05 |
Reporter | adminactoll | Assigned To | rombert | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.2.8 | ||||
Target Version | 1.2.12 | Fixed in Version | 1.2.12 | ||
Summary | 0013415: cloning issue with attachments doesn't work | ||||
Description | (Sorry for my bad english) The attached file is correctly uploaded in the original bug report and I'm able to open attached file (in original bug report) correctly. I spent time to debug this problem andI think the error is in file core/file_api.php between line 873 and 883. | ||||
Steps To Reproduce | Clone a bug report with attached file (with the box "clone attachments" selected). | ||||
Additional Information | ... #Error 1: function dirname returns parent directory of the parameter. When the variable $t_new_diskfile_name is created, projet folder of bug report is missing : so, new destintation file is invalid. #Error 2: About the first parameter of copy function, path of original attached file is missing. I resolve the problem with : $t_file_path = $t_bug_file['folder']; AND copy( $t_file_path.$t_bug_file['diskfile'], $t_new_diskfile_name ); | ||||
Tags | No tags attached. | ||||
Attached Files | 13415-v1.patch (1,131 bytes)
diff --git a/core/file_api.php b/core/file_api.php index 0073185..8938886 100644 --- a/core/file_api.php +++ b/core/file_api.php @@ -1041,11 +1041,12 @@ # prepare the new diskfile name and then copy the file $t_file_path = $t_bug_file['folder']; - $t_new_diskfile_name = $t_file_path . file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path ); + $t_new_diskfile_name = file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path ); + $t_new_diskfile_location = $t_file_path . $t_new_diskfile_name; $t_new_file_name = file_get_display_name( $t_bug_file['filename'] ); if(( config_get( 'file_upload_method' ) == DISK ) ) { - copy( $t_file_path.$t_bug_file['diskfile'], $t_new_diskfile_name ); - chmod( $t_new_diskfile_name, config_get( 'attachments_file_permissions' ) ); + copy( $t_file_path.$t_bug_file['diskfile'], $t_new_diskfile_location ); + chmod( $t_new_diskfile_location, config_get( 'attachments_file_permissions' ) ); } $query = "INSERT INTO $t_mantis_bug_file_table | ||||
Will look into this, thanks. |
|
Thanks for the report and the patch, I've applied the fix for both 1.2 and 1.3 . For the future, you could submit pull requests using github to get proper attribution in the codebase. |
|
I think this does not cover all of it. My understanding is that in mantis_bug_table the field 'diskfile' should only contains the generated filename WITHOUT the path, because the path is stored in field 'folder'. However in that case the patch is not complete: You should change line 873 from $t_new_diskfile_name = $t_file_path . file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path ); into $t_new_diskfile_name = file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path ); |
|
@TomR: Can you give me an example configuration and steps to reproduce? |
|
v1.1.18, in mantis_bug_table the field 'diskfile' includes the path, but in v2.1.8, in mantis_bug_table the field 'diskfile' does not includes the path. |
|
(In reply to comment 0013415:0031124)
This seems unrelated to the bug report, please use the forums for support or open a new bug. |
|
Reopened based on TomR's input 0013415:0030679
Check column diskfile of table manis_bug_file_table |
|
Also got the same issue when cloning a bug. $t_file_path = $t_bug_file['folder']; AND copy( $t_file_path.$t_bug_file['diskfile'], $t_new_diskfile_name ); AND Thus a new file will be created in the same folder of the original file and only file name will be saved to the diskfile column of mantis_bug_file_table. |
|
the last change should be: BTW, if the new folder is different from the older one, there should be more change to fix it. |
|
I've managed to reproduce the problem and with this fix I've now validated that cloning issues with attachments work as expected - the files are correctly copied and the diskfile entry is correct as well. Can anyone validate this patch for me before committing? |
|
Works for me. |
|
(In reply to comment 0013415:0032106)
Thanks for confirming. I was not sure my own tests were correct. |
|
Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch |
|
MantisBT: master 46873ebc 2011-11-14 09:05 Details Diff |
Fix 0013415 ( cloning issue with attachments doesn't work ) Thanks to adminactoll for providing the patch. |
Affected Issues 0013415 |
|
mod - core/file_api.php | Diff File | ||
MantisBT: master-1.2.x 0b8298ec 2011-11-14 09:05 Details Diff |
Fix 0013415 ( cloning issue with attachments doesn't work ) Thanks to adminactoll for providing the patch. |
Affected Issues 0013415 |
|
mod - core/file_api.php | Diff File | ||
MantisBT: master-1.2.x 92d2dc3b 2012-06-16 00:19 Details Diff |
Fix 0013415: cloning issue with attachments doesn't work |
Affected Issues 0013415 |
|
mod - core/file_api.php | Diff File | ||
MantisBT: master d8b21506 2012-06-16 00:19 Details Diff |
Fix 0013415: cloning issue with attachments doesn't work |
Affected Issues 0013415 |
|
mod - core/file_api.php | Diff File |