View Issue Details

IDProjectCategoryView StatusLast Update
0012540mantisbtapi soappublic2010-12-17 04:37
Reportersveyret Assigned Torombert  
PrioritylowSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Platformi686OSLinuxOS Version2.6.9
Product Version1.2.3 
Target Version1.2.4Fixed in Version1.2.4 
Summary0012540: mc_issue_attachment_get does not use the path for the file
Description

When trying to download an issue, I have a server error: Unable to find an attachment with type bug and id xxxxx.
This is due to a bug in the function mci_file_get (mc_file_api.php) where the field “diskfile” is used to retrieve the file, but without the field “folder” which gives the path to this file. Of course, the file is then not found.

Steps To Reproduce

Create a web service and use mc_issue_attachment_get to get the attachment of an issue.

Additional Information

I will create and attach a patch asap.

Tagspatch
Attached Files
soap_download.patch (619 bytes)   
diff -Naur mantisbt-1.2.3/api/soap/mc_file_api.php mantisbt-patch/api/soap/mc_file_api.php
--- mantisbt-1.2.3/api/soap/mc_file_api.php	2010-11-18 15:53:59.000000000 +0100
+++ mantisbt-patch/api/soap/mc_file_api.php	2010-11-18 15:56:40.000000000 +0100
@@ -175,9 +175,10 @@
 		$t_project_id = $row['project_id'];
 	} else if ( $p_type == 'bug' ) {
 		$t_bug_id = $row['bug_id'];
+		$t_project_id = bug_get_field( $t_bug_id, 'project_id' );
 	}
 
-	$t_diskfile = $row['diskfile'];
+	$t_diskfile = file_normalize_attachment_path( $row['diskfile'], $t_project_id );
 	$t_content = $row['content'];
 
 	# Check access rights
soap_download.patch (619 bytes)   

Activities

sveyret

sveyret

2010-11-18 09:16

reporter   ~0027411

Actually, it seems a little bit more complicated. It looks like Mantis used to store the full file name (including path) in the diskfile field, which is not the case anymore.

rombert

rombert

2010-11-18 09:20

reporter   ~0027412

Looks like something which I've also seen. Looking forward to your patch.

sveyret

sveyret

2010-11-18 10:07

reporter   ~0027414

Here it is, to be installed with “patch -p1” at the root of the Mantis installation directory (not a git patch, I really need to install git at my work!)
I tried to make the process look like the download process of file_download.php. My tests where successful, but I didn't have the possibility to make many of them.

Hope it will help!

rombert

rombert

2010-11-25 17:10

reporter   ~0027488

Thanks for the patch. I've applied it with your author credentials.

I suggest you look into git nevertheless :-)