aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-12-14 21:56:19 +0000
committerMario <mario@mariovavti.com>2020-12-14 21:56:19 +0000
commit8e488e291347857407dbedaf05d63941701d82d2 (patch)
tree52b9ca66fb3a9d9934000aca4c4860770dad7bb2
parente58e27ce2256ce4192c6ac7670ccb301fb40e60a (diff)
downloadvolse-hubzilla-8e488e291347857407dbedaf05d63941701d82d2.tar.gz
volse-hubzilla-8e488e291347857407dbedaf05d63941701d82d2.tar.bz2
volse-hubzilla-8e488e291347857407dbedaf05d63941701d82d2.zip
handle removal of terms in attach_delete() when deleting a ressource
-rw-r--r--Zotlabs/Module/Attach_edit.php11
-rw-r--r--include/attach.php8
2 files changed, 8 insertions, 11 deletions
diff --git a/Zotlabs/Module/Attach_edit.php b/Zotlabs/Module/Attach_edit.php
index 0a41dbb22..667a0b7aa 100644
--- a/Zotlabs/Module/Attach_edit.php
+++ b/Zotlabs/Module/Attach_edit.php
@@ -110,15 +110,7 @@ class Attach_edit extends Controller {
if ($delete) {
attach_delete($channel_id, $resource, $is_photo);
-
- q("DELETE FROM term WHERE uid = %d AND oid = %d AND otype = %d",
- intval($channel_id),
- intval($attach_id),
- intval(TERM_OBJ_FILE)
- );
-
$actions_done .= 'delete,';
-
}
if ($copy) {
@@ -161,9 +153,8 @@ class Attach_edit extends Controller {
store_item_tag($channel_id, $attach_id, TERM_OBJ_FILE, TERM_CATEGORY, $term, $term_link);
}
}
+ $actions_done .= 'cat_add,';
}
- $actions_done .= 'cat_add,';
-
}
else {
q("DELETE FROM term WHERE uid = %d AND oid = %d AND otype = %d",
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",