From 582919804a97262ae3a9ac8be7a09fd997e364de Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Wed, 5 Feb 2020 11:04:01 +0100 Subject: [PATCH] [ticket/16356] Delete attachments on saving a draft PHPBB3-16356 --- phpBB/includes/ucp/ucp_pm_compose.php | 4 ++++ phpBB/posting.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 2e1ad3fdcf..707df88edf 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -689,6 +689,10 @@ function compose_pm($id, $mode, $action, $user_folders = array()) ); $db->sql_query($sql); + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $attachment_manager->delete('attach', array_column($message_parser->attachment_data, 'attach_id')); + $redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=$mode"); meta_refresh(3, $redirect_url); diff --git a/phpBB/posting.php b/phpBB/posting.php index 27b75bf56d..a3b329026d 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -759,6 +759,10 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( ); $db->sql_query($sql); + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $attachment_manager->delete('attach', array_column($message_parser->attachment_data, 'attach_id')); + $meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); meta_refresh(3, $meta_info);