From 8e488e291347857407dbedaf05d63941701d82d2 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 14 Dec 2020 21:56:19 +0000 Subject: handle removal of terms in attach_delete() when deleting a ressource --- include/attach.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include/attach.php') diff --git a/include/attach.php b/include/attach.php index 515de9b4d..7ef5c4d0e 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1432,7 +1432,7 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { $channel_address = (($c) ? $c[0]['channel_address'] : 'notfound'); $photo_sql = (($is_photo) ? " and is_photo = 1 " : ''); - $r = q("SELECT hash, os_storage, flags, is_dir, is_photo, folder FROM attach WHERE hash = '%s' AND uid = %d $photo_sql limit 1", + $r = q("SELECT id, hash, os_storage, flags, is_dir, is_photo, folder FROM attach WHERE hash = '%s' AND uid = %d $photo_sql limit 1", dbesc($resource), intval($channel_id) ); @@ -1453,6 +1453,12 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { return; } + q("DELETE FROM term WHERE uid = %d AND oid = %d AND otype = %d", + intval($channel_id), + intval($r[0]['id']), + intval(TERM_OBJ_FILE) + ); + // If resource is a directory delete everything in the directory recursive if(intval($r[0]['is_dir'])) { $x = q("SELECT hash, os_storage, is_dir, flags FROM attach WHERE folder = '%s' AND uid = %d", -- cgit v1.2.3