better deleting of user's uploads

This commit is contained in:
Shish 2021-12-13 01:27:49 +00:00
parent 674a821783
commit b2ceb36499

View file

@ -730,9 +730,9 @@ class UserPage extends Extension
if ($with_images) {
log_warning("user", "Deleting user #{$_POST['id']} (@{$duser->name})'s uploads");
$rows = $database->get_all("SELECT * FROM images WHERE owner_id = :owner_id", ["owner_id" => $_POST['id']]);
foreach ($rows as $key => $value) {
$image = Image::by_id($value['id']);
$image_ids = $database->get_col("SELECT id FROM images WHERE owner_id = :owner_id", ["owner_id" => $_POST['id']]);
foreach ($image_ids as $image_id) {
$image = Image::by_id((int)$image_id);
if ($image) {
send_event(new ImageDeletionEvent($image));
}