Skip to content

Commit

Permalink
Fixed a problem in case of FTP uploads, where if the bug was deleted the
Browse files Browse the repository at this point in the history
files on the webserver/ftp server were not deleted.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1174 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Jul 7, 2002
1 parent 8823df0 commit 18e908b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
14 changes: 8 additions & 6 deletions core_file_API.php
Expand Up @@ -4,11 +4,11 @@
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Revision: 1.1 $
# $Revision: 1.2 $
# $Author: vboctor $
# $Date: 2002-07-06 15:02:43 $
# $Date: 2002-07-07 06:28:14 $
#
# $Id: core_file_API.php,v 1.1 2002-07-06 15:02:43 vboctor Exp $
# $Id: core_file_API.php,v 1.2 2002-07-07 06:28:14 vboctor Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -91,7 +91,7 @@ function file_ftp_get ( $p_conn_id, $p_local_filename, $p_remote_filename ) {
# --------------------
# Delete a file from the ftp server
function file_ftp_delete ( $p_conn_id, $p_filename ) {
ftp_delete( $p_conn_id, $p_filename );
@ftp_delete( $p_conn_id, $p_filename );
}
# --------------------
# Disconnect from the ftp server
Expand All @@ -102,7 +102,9 @@ function file_ftp_disconnect( $p_conn_id ) {
# Delete a local file even if it is read-only.
function file_delete_local( $p_filename ) {
# in windows replace with system("del $t_diskfile");
chmod( $p_filename, 0775 );
unlink( $p_filename );
if ( file_exists( $p_filename ) ) {
chmod( $p_filename, 0775 );
unlink( $p_filename );
}
}
?>
22 changes: 12 additions & 10 deletions core_helper_API.php
Expand Up @@ -5,11 +5,11 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Revision: 1.51 $
# $Revision: 1.52 $
# $Author: vboctor $
# $Date: 2002-07-04 10:00:59 $
# $Date: 2002-07-07 06:28:14 $
#
# $Id: core_helper_API.php,v 1.51 2002-07-04 10:00:59 vboctor Exp $
# $Id: core_helper_API.php,v 1.52 2002-07-07 06:28:14 vboctor Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -195,9 +195,9 @@ function delete_bug( $p_id, $p_bug_text_id ) {
WHERE bug_id='$c_id'";
$result = db_query($query);

if ( DISK == $g_file_upload_method ) {
if ( ( DISK == $g_file_upload_method ) || ( FTP == $g_file_upload_method ) ) {
# Delete files from disk
$query = "SELECT diskfile
$query = "SELECT diskfile, filename
FROM $g_mantis_bug_file_table
WHERE bug_id='$c_id'";
$result = db_query($query);
Expand All @@ -206,12 +206,14 @@ function delete_bug( $p_id, $p_bug_text_id ) {
# there may be more than one file
for ($i=0;$i<$file_count;$i++){
$row = db_fetch_array( $result );
$t_diskfile = $row['diskfile'];

# use this instead of delete;
# in windows replace with system("del $t_diskfile");
chmod( $t_diskfile, 0775 );
unlink( $t_diskfile );
file_delete_local ( $row['diskfile'] );

if ( FTP == $g_file_upload_method ) {
$ftp = file_ftp_connect();
file_ftp_delete ( $ftp, $row['filename'] );
file_ftp_disconnect( $ftp );
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion report_add.php
Expand Up @@ -218,7 +218,7 @@
$result = db_query( $query );

# log new bug
history_log_event_special( $f_id, FILE_ADDED, file_get_display_name( $f_file_name ) );
history_log_event_special( $t_bug_id, FILE_ADDED, file_get_display_name( $f_file_name ) );
}

# Notify users of new bug report
Expand Down

0 comments on commit 18e908b

Please sign in to comment.