1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-06 14:35:56 +02:00

Merge branch '3.2.x'

This commit is contained in:
Marc Alexander 2018-10-20 12:17:09 -04:00
commit dc2170bd64
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995

View File

@ -99,6 +99,8 @@ class delete
$this->set_sql_constraints($mode); $this->set_sql_constraints($mode);
$sql_id = $this->sql_id;
/** /**
* Perform additional actions before collecting data for attachment(s) deletion * Perform additional actions before collecting data for attachment(s) deletion
* *
@ -117,11 +119,21 @@ class delete
); );
extract($this->dispatcher->trigger_event('core.delete_attachments_collect_data_before', compact($vars))); extract($this->dispatcher->trigger_event('core.delete_attachments_collect_data_before', compact($vars)));
$this->sql_id = $sql_id;
unset($sql_id);
// Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled) // Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled)
$this->collect_attachment_info($resync); $this->collect_attachment_info($resync);
// Delete attachments from database // Delete attachments from database
$this->delete_attachments_from_db(); $this->delete_attachments_from_db($mode, $ids, $resync);
$sql_id = $this->sql_id;
$post_ids = $this->post_ids;
$topic_ids = $this->topic_ids;
$message_ids = $this->message_ids;
$physical = $this->physical;
$num_deleted = $this->num_deleted;
/** /**
* Perform additional actions after attachment(s) deletion from the database * Perform additional actions after attachment(s) deletion from the database
@ -151,13 +163,21 @@ class delete
); );
extract($this->dispatcher->trigger_event('core.delete_attachments_from_database_after', compact($vars))); extract($this->dispatcher->trigger_event('core.delete_attachments_from_database_after', compact($vars)));
$this->sql_id = $sql_id;
$this->post_ids = $post_ids;
$this->topic_ids = $topic_ids;
$this->message_ids = $message_ids;
$this->physical = $physical;
$this->num_deleted = $num_deleted;
unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical, $num_deleted);
if (!$this->num_deleted) if (!$this->num_deleted)
{ {
return 0; return 0;
} }
// Delete attachments from storage // Delete attachments from storage
$this->remove_from_storage(); $this->remove_from_storage($mode, $ids, $resync);
// If we do not resync, we do not need to adjust any message, post, topic or user entries // If we do not resync, we do not need to adjust any message, post, topic or user entries
if (!$resync) if (!$resync)
@ -283,8 +303,14 @@ class delete
/** /**
* Delete attachments from database table * Delete attachments from database table
*/ */
protected function delete_attachments_from_db() protected function delete_attachments_from_db($mode, $ids, $resync)
{ {
$sql_id = $this->sql_id;
$post_ids = $this->post_ids;
$topic_ids = $this->topic_ids;
$message_ids = $this->message_ids;
$physical = $this->physical;
/** /**
* Perform additional actions before attachment(s) deletion * Perform additional actions before attachment(s) deletion
* *
@ -311,6 +337,13 @@ class delete
); );
extract($this->dispatcher->trigger_event('core.delete_attachments_before', compact($vars))); extract($this->dispatcher->trigger_event('core.delete_attachments_before', compact($vars)));
$this->sql_id = $sql_id;
$this->post_ids = $post_ids;
$this->topic_ids = $topic_ids;
$this->message_ids = $message_ids;
$this->physical = $physical;
unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical);
// Delete attachments // Delete attachments
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $this->db->sql_in_set($this->sql_id, $this->ids); WHERE ' . $this->db->sql_in_set($this->sql_id, $this->ids);
@ -324,7 +357,7 @@ class delete
/** /**
* Delete attachments from storage * Delete attachments from storage
*/ */
protected function remove_from_storage() protected function remove_from_storage($mode, $ids, $resync)
{ {
$space_removed = $files_removed = 0; $space_removed = $files_removed = 0;
@ -343,6 +376,13 @@ class delete
} }
} }
$sql_id = $this->sql_id;
$post_ids = $this->post_ids;
$topic_ids = $this->topic_ids;
$message_ids = $this->message_ids;
$physical = $this->physical;
$num_deleted = $this->num_deleted;
/** /**
* Perform additional actions after attachment(s) deletion from the filesystem * Perform additional actions after attachment(s) deletion from the filesystem
* *
@ -375,6 +415,14 @@ class delete
); );
extract($this->dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars))); extract($this->dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars)));
$this->sql_id = $sql_id;
$this->post_ids = $post_ids;
$this->topic_ids = $topic_ids;
$this->message_ids = $message_ids;
$this->physical = $physical;
$this->num_deleted = $num_deleted;
unset($sql_id, $post_ids, $topic_ids, $message_ids, $physical, $num_deleted);
if ($space_removed || $files_removed) if ($space_removed || $files_removed)
{ {
$this->config->increment('upload_dir_size', $space_removed * (-1), false); $this->config->increment('upload_dir_size', $space_removed * (-1), false);