[ticket/15755] Fix event vars in /phpbb/attachment/delete.php

PHPBB3-15755
This commit is contained in:
rxu 2018-08-12 21:54:13 +07:00
parent bd90a53589
commit fc674873c7

View file

@ -104,6 +104,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
* *
@ -122,11 +124,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
@ -156,13 +168,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 filesystem // Delete attachments from filesystem
$this->remove_from_filesystem(); $this->remove_from_filesystem($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)
@ -288,8 +308,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
* *
@ -316,6 +342,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);
@ -329,7 +362,7 @@ class delete
/** /**
* Delete attachments from filesystem * Delete attachments from filesystem
*/ */
protected function remove_from_filesystem() protected function remove_from_filesystem($mode, $ids, $resync)
{ {
$space_removed = $files_removed = 0; $space_removed = $files_removed = 0;
@ -348,6 +381,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
* *
@ -380,6 +420,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);