File Attachments in Mantis 1.2RC2

Get help from other users here.

Moderators: Developer, Contributor

File Attachments in Mantis 1.2RC2

Postby Holger » Dec 09, 2009 5:59 am

Hi Development Team!

I just did my first ever steps with Mantis (1.2RC2).

I really really love this software and don’t know why I was using Excel sheets for Bugtracking so long.

However, I have an issue with Mantis and I hope you are able to help me with that, as I couldn't find a thread here which seemed to be the correct answer for my problem:

Whenever I have an attachment to an issue, I am not able to view or use this information later on. In case of jpg or png attachments i get error messages like this:
SYSTEM WARNING: finfo::finfo() [finfo.finfo]: Failed to load magic database at ”.
SYSTEM WARNING: finfo::buffer() [finfo.buffer]: The invalid fileinfo object.

followed by loads of jabber of something that might be my pic:
‰PNG  IHDR(„RדciCCPICC ProfilexízWTA×muOdfÈ99g$*’3ˆ….
followed by:

SYSTEM WARNING: Cannot modify header information – headers already sent by (output started at /PathToMantis/mantisbt/core/error_api.php:202)

If the attachment is a zip-file Mantis downloads a html file which looks very similar to the above.

Bug or Mistake on my side???
Help is very much appreciated
Holger
Holger
 
Posts: 3
Joined: Dec 09, 2009 4:55 am

Re: File Attachments in Mantis 1.2RC2

Postby Kirill » Dec 10, 2009 4:34 am

What version of PHP?
Try use this patch
http://git.mantisbt.org/?p=mantisbt.git ... a4ae0e3852
Kirill
 
Posts: 274
Joined: Nov 25, 2007 3:05 am
Location: Kaliningrad, RF

Re: File Attachments in Mantis 1.2RC2

Postby Holger » Dec 10, 2009 5:07 am

Hi kirill!

Thank you for your answer.

The PHP version used is:
PHP 5.3.0

I have replaced the file_download.php with the patch you've provided.

Now, I get a totally different error message:
APPLICATION ERROR #401
Datenbankabfrage fehlgeschlagen (database query failed). Die Reportmeldung lautet #1064:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'WHERE id=6' at line 3 for query: SELECT * FROM WHERE id=?.

And:
APPLICATION WARNING #100: Konfigurationsoption „bug_file“ nicht gefunden. (configuration option "bug_file" not found)

Sounds like I did make a mistake in configure Mantis correctly.
Can you help again ??

Thanx
Holger
 
Posts: 3
Joined: Dec 09, 2009 4:55 am

Re: File Attachments in Mantis 1.2RC2

Postby atrol » Dec 10, 2009 5:37 am

Holger wrote:The PHP version used is:
PHP 5.3.0

Just assumption
5.3.x seems not to be a good version for MantisBT at the moment
For example have a look at:
http://www.mantisbt.org/bugs/view.php?id=11048

As these are your first steps with MantisBT, starting with environments that are known as stable might be a better way for you.
atrol
 
Posts: 804
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: File Attachments in Mantis 1.2RC2

Postby protatoe » Dec 11, 2009 3:46 am

I ran into the same issue myself when upgrading from 1.1.8 to 1.2. The patch does indeed work, but with a little tweaking. Either way I can once again view attached screen shots. Thanks for the patch!

previous code in the patched file_download.php, starting line 45
Code: Select all
   switch ( $f_type ) {
      case 'bug':
         $t_bug_file_table = db_get_table( 'bug_file' );
         $query = "SELECT *
            FROM $t_bug_file_table
            WHERE id=" . db_param();
         
         break;
      case 'doc':
         $t_project_file_table = db_get_table( 'project_file' );
         $query = "SELECT *
            FROM $t_project_file_table
            WHERE id=" . db_param();
         
         break;
      default:
         access_denied();
   }
   $result = db_query_bound( $query, Array( $c_file_id ) );
   $row = db_fetch_array( $result );


And the same code with changes, just updated the db_get_table to the correct string. I also put $c_file_id directly into the query string and removed the array op including it from the db_query call. Doing so stopped the first mysql error, replacing the table names stopped the second and allowed the patched file_download.php do it's thing.
Code: Select all
   switch ( $f_type ) {
      case 'bug':
         $t_bug_file_table = db_get_table( 'mantis_bug_file_table' );
         $query = "SELECT *
            FROM $t_bug_file_table
            WHERE id=" . $c_file_id;

         break;
      case 'doc':
         $t_project_file_table = db_get_table( 'mantis_project_file_table' );
         $query = "SELECT *
            FROM $t_project_file_table
            WHERE id=" . $c_file_id;

         break;
      default:
         access_denied();
   }

   $result = db_query_bound( $query );
   $row = db_fetch_array( $result );
protatoe
 
Posts: 1
Joined: Dec 11, 2009 3:33 am

Re: File Attachments in Mantis 1.2RC2

Postby neozeta » Dec 13, 2009 3:19 pm

Hi everybody!,

I have the same problem.
I'm updated a mantis 1.0.6 (yes, very old :-)) to 1.2.0rc2 for use the mail to issue plugin (for 1.2.0rc2)

My scenario configuration:
Windows 7 64bit
As I read that php 5.3.x seems not a good version for this rc2, i'm choose the xampp 1.5.5 that have a php 5.2.0 version.

For use the "mime magic" or "fileinfo" extension, I'm uncommented the line "extension=php_fileinfo.dll" in the php.ini file. xampp is installed by default magic extension.
Still, it seems not recognice the class "finfo", and $content_type is not properly informed.

At the moment, i'm solved the problem with this "fix", from the line 140 in every if($finfo_available){, i'm added:

Code: Select all
            if ( $finfo_available ) {
               if ( $content_type = $finfo->file( $t_local_disk_file ) ) {
                  header( 'Content-Type: ' . $content_type );
               }
            }else{
               header( 'Content-Type: ' . $v_file_type );
            }


This appears to work well, since we use the file type that is registered in the database


Also, when a file is download, ever the default name of the file is "file_download.zip, or file_download.jpg, etc...
This i'm fixed editing the line 108:

Code: Select all
header( 'Content-Disposition:' . $t_disposition . ' filename*=UTF-8\'\'' . urlencode( $t_filename ) . '; filename="' . urlencode( $t_filename ) . '"' );


for this:

Code: Select all
header( 'Content-Disposition: attachment; filename="' . urlencode( $v_filename ) . '"' );


So far it seems to work correctly.
Si alguien tiene alguna idea de porque no está funcionando de la otra manera, se lo agradeceré any idea.

Thanks!

(and excuse my english ;-))
neozeta
 
Posts: 1
Joined: Dec 13, 2009 2:47 pm

Re: File Attachments in Mantis 1.2RC2

Postby Holger » Dec 14, 2009 5:52 am

Hi all!

I am amazed by the excellent quality of the posts in this forum!!
For an absolute beginner with Mantis this is like a warm shower - or nice christmas presents!

Looks like protatoe did a very good job in patching the patched file.
All attachment data already in the database is now viewable or usable.

However , I am still not able to upload attachments to new or existing bugreports.
This gives me an 401 error and asks me to use the browsers back button...

Any ideas on this as well

THANKS SO MUCH
Holger
 
Posts: 3
Joined: Dec 09, 2009 4:55 am

Re: File Attachments in Mantis 1.2RC2

Postby Kirill » Dec 14, 2009 7:56 am

Try this settings in config_inc.php
Code: Select all
   $g_display_errors = array(
      E_WARNING => 'inline',
      E_NOTICE => 'inline',
      E_USER_ERROR => 'halt',
      E_USER_WARNING => 'inline',
      E_USER_NOTICE => 'inline'
   );
Kirill
 
Posts: 274
Joined: Nov 25, 2007 3:05 am
Location: Kaliningrad, RF

Re: File Attachments in Mantis 1.2RC2

Postby ninsky » Dec 18, 2009 4:47 am

I have the same problem :(

My Env:
php: 5.3.0
CentoOS
Apache 2.2.3


The solutions of above are not work for me :evil:

Must change the php to 5.2?
ninsky
 
Posts: 2
Joined: Dec 18, 2009 4:42 am

Re: File Attachments in Mantis 1.2RC2

Postby 675343 » Apr 01, 2010 6:11 am

Holger wrote:Hi Development Team!

...

Bug or Mistake on my side???
Help is very much appreciated
Holger

Hello.

I had the same problem, when started migrate from 1.0.6 to 1.2.0, but i found the solution:

1). open file $MANTIS_DIR/file_download.php
2). find key string "if ( class_exists( 'finfo' ) ) {" and replace it with "if ( false ) {" and save the document.

Good luck!
675343
 
Posts: 1
Joined: Apr 01, 2010 5:10 am


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests