Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ac8630b

Browse files
committedOct 18, 2011
Fix #8504: Use is_blank() not '' to check empty path in file_add()
1 parent 52ac5d2 commit ac8630b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed
 

‎core/file_api.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,11 @@ function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc
646646
$t_file_path = config_get( 'absolute_path_default_upload_folder' );
647647
} else {
648648
$t_file_path = project_get_field( $t_project_id, 'file_path' );
649-
if( $t_file_path == '' ) {
649+
if( is_blank( $t_file_path ) ) {
650650
$t_file_path = config_get( 'absolute_path_default_upload_folder' );
651651
}
652652
}
653+
653654
$c_file_path = db_prepare_string( $t_file_path );
654655
$c_new_file_name = db_prepare_string( $t_file_name );
655656

@@ -848,26 +849,26 @@ function file_get_extension( $p_filename ) {
848849
}
849850

850851
/**
851-
*
852+
*
852853
* Copies all attachments from the source bug to the destination bug
853-
*
854+
*
854855
* <p>Does not perform history logging and does not perform access checks.</p>
855-
*
856+
*
856857
* @param int $p_source_bug_id
857858
* @param int $p_dest_bug_id
858859
*/
859860
function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
860-
861+
861862
$t_mantis_bug_file_table = db_get_table( 'mantis_bug_file_table' );
862-
863+
863864
$query = 'SELECT * FROM ' . $t_mantis_bug_file_table . ' WHERE bug_id = ' . db_param();
864865
$result = db_query_bound( $query, Array( $p_source_bug_id ) );
865866
$t_count = db_num_rows( $result );
866-
867+
867868
$t_bug_file = array();
868869
for( $i = 0;$i < $t_count;$i++ ) {
869870
$t_bug_file = db_fetch_array( $result );
870-
871+
871872
# prepare the new diskfile name and then copy the file
872873
$t_file_path = dirname( $t_bug_file['folder'] );
873874
$t_new_diskfile_name = $t_file_path . file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path );
@@ -876,7 +877,7 @@ function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
876877
copy( $t_bug_file['diskfile'], $t_new_diskfile_name );
877878
chmod( $t_new_diskfile_name, config_get( 'attachments_file_permissions' ) );
878879
}
879-
880+
880881
$query = "INSERT INTO $t_mantis_bug_file_table
881882
( bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content )
882883
VALUES ( " . db_param() . ",
@@ -891,4 +892,4 @@ function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
891892
" . db_param() . ");";
892893
db_query_bound( $query, Array( $p_dest_bug_id, $t_bug_file['title'], $t_bug_file['description'], $t_new_diskfile_name, $t_new_file_name, $t_bug_file['folder'], $t_bug_file['filesize'], $t_bug_file['file_type'], $t_bug_file['date_added'], $t_bug_file['content'] ) );
893894
}
894-
}
895+
}

0 commit comments

Comments
 (0)
Please sign in to comment.