/core/file_api.php' line 877 when cloning with attachment

MantisBT forum for users who prefer to ask and answer questions in Russian.

Moderators: Developer, Contributor

Post Reply
alphaed
Posts: 43
Joined: 07 Aug 2012, 09:24

/core/file_api.php' line 877 when cloning with attachment

Post by alphaed »

Нажимаю клонировать, ставлю галку с вложениями.
Получаю

Code: Select all

SYSTEM WARNING: 'copy(/usr/local/www/helpdesk/attachments//usr/local/www/helpdesk/attachments/cad04bf57ff24baad09cb0ccd17cb3a0) [function.copy]: failed to open stream: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 877

SYSTEM WARNING: 'chmod() [function.chmod]: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 878

SYSTEM WARNING: 'copy(/usr/local/www/helpdesk/attachments//usr/local/www/helpdesk/attachments/2801a4ac1f66e10fccb6847e79394ad6) [function.copy]: failed to open stream: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 877

SYSTEM WARNING: 'chmod() [function.chmod]: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 878

SYSTEM WARNING: 'copy(/usr/local/www/helpdesk/attachments//usr/local/www/helpdesk/attachments/794ffe60edbf5993005f598982adbaf0) [function.copy]: failed to open stream: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 877

SYSTEM WARNING: 'chmod() [function.chmod]: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 878
В настройках -

Code: Select all

$g_file_upload_method = DISK;
вот строки с 876 по 879

Code: Select all

  if(( config_get( 'file_upload_method' ) == DISK ) ) {
            copy( $t_file_path.$t_bug_file['diskfile'], $t_new_diskfile_name );
            chmod( $t_new_diskfile_name, config_get( 'attachments_file_permissions' ) );
        }
MantisBT Version 1.2.11
Kirill
Posts: 638
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: /core/file_api.php' line 877 when cloning with attachmen

Post by Kirill »

https://github.com/mantisbt/mantisbt/co ... a1af4b2365
Сделали изменения, которые появятся в слудеющем релизе. Вы можете протестировать, скачав текущие исходники https://github.com/mantisbt/mantisbt/zi ... ster-1.2.x.
alphaed
Posts: 43
Joined: 07 Aug 2012, 09:24

Re: /core/file_api.php' line 877 when cloning with attachmen

Post by alphaed »

Насколько я понял к сабжу относятся вот эти изменения
Применил.

в первый раз выдало

Code: Select all

SYSTEM WARNING: 'copy(/usr/local/www/helpdesk/attachments/d6c3f266821fc2df691a9103e3e0642c) [function.copy]: failed to open stream: Permission denied' in '/usr/local/www/helpdesk/core/file_api.php' line 894
SYSTEM WARNING: 'chmod() [function.chmod]: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 895
SYSTEM WARNING: 'copy(/usr/local/www/helpdesk/attachments/ee399a7514f6d8b58c937552f420cdd3) [function.copy]: failed to open stream: Permission denied' in '/usr/local/www/helpdesk/core/file_api.php' line 894
SYSTEM WARNING: 'chmod() [function.chmod]: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 895
дал права на 660 на файлики в папке /usr/local/www/helpdesk/attachments/ и попытался еще раз.

выдало

Code: Select all

SYSTEM WARNING: 'copy() [function.copy]: Filename cannot be empty' in '/usr/local/www/helpdesk/core/file_api.php' line 894
SYSTEM WARNING: 'chmod() [function.chmod]: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 895
SYSTEM WARNING: 'copy() [function.copy]: Filename cannot be empty' in '/usr/local/www/helpdesk/core/file_api.php' line 894
SYSTEM WARNING: 'chmod() [function.chmod]: No such file or directory' in '/usr/local/www/helpdesk/core/file_api.php' line 895
core/file_api.php строки с 860 по 914

Code: Select all

function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {

    $t_mantis_bug_file_table = db_get_table( 'mantis_bug_file_table' );

    $query = 'SELECT * FROM ' . $t_mantis_bug_file_table . ' WHERE bug_id = ' . db_param();
    $result = db_query_bound( $query, Array( $p_source_bug_id ) );
    $t_count = db_num_rows( $result );

	$t_project_id = bug_get_field( $p_source_bug_id, 'project_id' );
	
    $t_bug_file = array();
    for( $i = 0;$i < $t_count;$i++ ) {
        $t_bug_file = db_fetch_array( $result );

        # prepare the new diskfile name and then copy the file
        //$t_file_path = $t_bug_file['folder'];
		
		$t_source_file = $t_bug_file['folder'] . $t_bug_file['diskfile'];
		if(( config_get( 'file_upload_method' ) == DISK ) ) {
			$t_source_file = file_normalize_attachment_path( $t_source_file, $t_project_id );
			$t_file_path = dirname( $t_source_file ) . DIRECTORY_SEPARATOR;
		} else {
			$t_file_path = $t_bug_file['folder'];
		}
		
		
        $t_new_diskfile_name = $t_file_path . file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path );
        $t_new_file_name = file_get_display_name( $t_bug_file['filename'] );
        if(( config_get( 'file_upload_method' ) == DISK ) ) {
            //copy( $t_file_path.$t_bug_file['diskfile'], $t_new_diskfile_name );
            //chmod( $t_new_diskfile_name, config_get( 'attachments_file_permissions' ) );
			# Skip copy operation if file does not exist (i.e. target bug will have missing attachment)
			# @todo maybe we should trigger an error instead in this case ?
			if( file_exists( $t_source_file ) ) {
				copy( $t_source_file, $t_new_diskfile_location );
				chmod( $t_new_diskfile_location, config_get( 'attachments_file_permissions' ) );
			}
        }

        $query = "INSERT INTO $t_mantis_bug_file_table
    						( bug_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content )
    						VALUES ( " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ",
    								 " . db_param() . ");";
        //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'] ) );
		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_file_path, $t_bug_file['filesize'], $t_bug_file['file_type'], $t_bug_file['date_added'], $t_bug_file['content'] ) );
    }
}
Или еще где-то что-то надо поменять?

п.с. заявки новые создаются, но файлики в них - "Вложение отсутствует"
alphaed
Posts: 43
Joined: 07 Aug 2012, 09:24

Re: /core/file_api.php' line 877 when cloning with attachmen

Post by alphaed »

Разобрался.
Видать туда вносили изменения ранее.

Code: Select all

$t_new_diskfile_name = file_generate_unique_name( 'bug-' . $t_bug_file['filename'], $t_file_path );
$t_new_diskfile_location = $t_file_path . $t_new_diskfile_name;
$t_new_file_name = file_get_display_name( $t_bug_file['filename'] );
все работает. спасибо.
Post Reply