View Issue Details

IDProjectCategoryView StatusLast Update
0021635mantisbtadministrationpublic2019-12-03 06:25
ReporterKenMcGinnis Assigned To 
Status feedbackResolutionopen 
PlatformWindows Server 2012 R2OSWindows Server 2012 R2OS VersionServer 2012 R2
Product Version1.3.0 
Summary0021635: Problems with corrupting database with use of $g_absolute_path_default_upload_folder = 'Files/';

First I'll list my settings:

config_inc.php values:

$g_allow_file_upload    = ON;
$g_file_upload_method   = DISK;
$g_absolute_path_default_upload_folder = 'Files/';

Bug 1. See screenshot for Failed errors with
Why show errors when attaching a file to an issue actually works and saves the attached file in the mantis/Files folder correctly. I can attache the file. It is saved when I look in the Files folder and I can download the attached file from the mantis issue. So, the Files folder is setup correctly and is writable and is accessible. The admin/check/index.php tests are wrong. this needs to be fixed.

Bug 2. See screenshots for an error when updating a project.
Steps: Mangage -> Manage Projects -> click the Project to Edit -> Don't make any changes and the value of "Files/" is automatically filled in. It comes from the config_inc.php file -> now click the Update Project button ->

Notice from screenshot (z-mantis-2.jpg) that Upload File Path is automatically filled in with the value of "Files/" each time I edit a project.

Re-edit project after last save. Bug, \ character added to "Files/\"

Now database is corrupted with extra \ character added to "Files/\"
Bug 3. Project table is now corrupt with extra \ character added to "Files/\".
See screenshot of table 'mantis_project_table' and the 'file_path' field.

BUG 4. New attachments saved in the file table is corrupt for any attachments added after the Edit and Update of a Mantis project.
See screenshot of table 'mantis_bug_file_table' and the 'folder' field.

Notes: I have found that the only work around (so that the database is not corrupted) is to edit the mySQL database directly to blank out the "Upload File Path" for the project each time I edit a project. By blanking it out in the mantis_project_table the database correctly gets the value of "Files/" added to the 'mantis_bug_file_table' folder field. If I forget then the mantis_bug_file_table also becomes corrupted with the extra \ character added to the end of the Files/\ value. I then have to edit manually and remove all the extra \ character from all attachment records added after a project was edited so that the attachments can be view/downlaoded by users.

EDIT (dregad) fix markdown

TagsNo tags attached.


related to 0020602 closeddregad absolute_path_default_upload_folder has a trailing directory separator: "Files/" 




2016-08-20 23:40

reporter   ~0053868

Related to Mantis Issue 20602 reported before. Hopefully this time I have documented it well enough for it to get fixed.



2016-08-21 04:58

developer   ~0053869

Last edited: 2016-08-21 05:00

The first question remains the same 0020602:0052521
Do you work on Windows?
[Edit] Just saw that you are on Windows Server 2012 R2

If so, does it work with 'Files\' ?



2016-08-21 09:03

developer   ~0053870

Last edited: 2019-12-03 06:25


function validate_project_file_path does not just validate the path but changes also the path in some cases as it calls terminate_directory_path( $p_file_path );
This is convenient for some use cases, but the root cause of mentioned bug 2.
I think that validation functions should never change any value.

Furthermore file_ensure_valid_upload_path is not called in function validate_project_file_path if path == config_get( 'absolute_path_default_upload_folder' )
I think it's better to check always any path as absolute_path_default_upload_folder might also be invalid.

So the function would look like:

function validate_project_file_path( $p_file_path ) {
    if( !is_blank( $p_file_path ) ) {

        file_ensure_valid_upload_path( $p_file_path );
        # If the provided path is the same as the default, make the path blank.
        # This means that if the default upload path is changed, you don't have
        # to update the upload path for every single project.
        if( !strcmp( $p_file_path, config_get( 'absolute_path_default_upload_folder' ) ) ) {
            $p_file_path = '';

    return $p_file_path;

This might introduce regressions on some installations, but I don't like that much such kind of partial self healing stuff.

EDIT (dregad) fix markdown



2016-08-21 19:06

reporter   ~0053874

No. If I change:
$g_absolute_path_default_upload_folder = 'Files/';
to be
$g_absolute_path_default_upload_folder = 'Files\';
and save the file then hit refresh in chrome to refresh the page I get an error: "The zzzzz page isn't working. xxxxx is currently unable to handle this request. HTTP ERROR 500" with a "Reload" button.
If I change it back to 'Files/' the page loads just fine. I have my site default to View Issues. The view_all_bug_page.php is the page that will no longer load if I change the setting to 'Files\'.



2016-08-21 19:08

reporter   ~0053875

atrol, if you don't have a Windows server to test on I'd be happy to do a google hangout or skype call where I could share my screen and we could try anything you want.



2016-08-22 02:17

developer   ~0053876

I have no time at the moment to have a deeper look at it.
Just want to mention that $g_absolute_path_default_upload_folder is the
absolute path to the default upload folder, thus it should be set to something like 'c:\mantis\files\'



2016-08-22 03:23

reporter   ~0053877

All of the exact same problems.

And page gets same error and can't load.

It works until I edit a project and then it adds the \ to the end of it.

If it's the absolute path (full path) then the documentation needs to be changed to state that instead of the example they show of 'Files/'



2016-08-22 03:28

reporter   ~0053878

And not modifying a project to mess it up and now all of my 'mantis_bug_file_table' records for new attachments has a full path in the 'folder' field. All my other records only have 'Files/' in the 'folder' field.



2016-08-23 03:10

developer   ~0053881

Last edited: 2019-12-03 06:25

If it's the absolute path (full path) then the documentation needs to be changed

I don't see any documentation for this option in Admin Guide.
This is what we have in config_defaults_inc.php

 * absolute path to the default upload folder.  Requires trailing / or \
 * @global string $g_absolute_path_default_upload_folder
$g_absolute_path_default_upload_folder = '';

EDIT (dregad) fix markdown