aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-06-12 12:46:29 +0200
committerMario Vavti <mario@mariovavti.com>2019-06-12 12:46:29 +0200
commitbc34167c8490c2dad5fcd6553b27b5df54449c39 (patch)
treedd06121fb98cf12cc75d0faa0074ae6832a4b894
parentdecd0dc035cce0918519bef77742ff87db23e3f3 (diff)
downloadvolse-hubzilla-bc34167c8490c2dad5fcd6553b27b5df54449c39.tar.gz
volse-hubzilla-bc34167c8490c2dad5fcd6553b27b5df54449c39.tar.bz2
volse-hubzilla-bc34167c8490c2dad5fcd6553b27b5df54449c39.zip
port delete fixes from zap
-rw-r--r--Zotlabs/Lib/Libzot.php22
-rw-r--r--include/zot.php23
2 files changed, 25 insertions, 20 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index ba9ffbead..0ad8afc94 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -2037,7 +2037,7 @@ class Libzot {
$item_found = false;
$post_id = 0;
- $r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
+ $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
and mid = '%s' and uid = %d limit 1",
dbesc($sender),
dbesc($sender),
@@ -2047,10 +2047,12 @@ class Libzot {
);
if($r) {
- if($r[0]['author_xchan'] === $sender || $r[0]['owner_xchan'] === $sender || $r[0]['source_xchan'] === $sender)
+ $stored = $r[0];
+
+ if($stored['author_xchan'] === $sender || $stored['owner_xchan'] === $sender || $stored['source_xchan'] === $sender)
$ownership_valid = true;
- $post_id = $r[0]['id'];
+ $post_id = $stored['id'];
$item_found = true;
}
else {
@@ -2074,15 +2076,15 @@ class Libzot {
return false;
}
- if ($item['obj_type'] == ACTIVITY_OBJ_EVENT) {
+ if ($stored['resource_type'] === 'event') {
$i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
- dbesc($item['uuid']),
+ dbesc($stored['resource_id']),
intval($uid)
);
if ($i) {
if ($i[0]['event_xchan'] === $sender) {
q("delete from event where event_hash = '%s' and uid = %d",
- dbesc($item['uuid']),
+ dbesc($stored['resource_id']),
intval($uid)
);
}
@@ -2094,7 +2096,7 @@ class Libzot {
}
if($item_found) {
- if(intval($r[0]['item_deleted'])) {
+ if(intval($stored['item_deleted'])) {
logger('delete_imported_item: item was already deleted');
if(! $relay)
return false;
@@ -2106,10 +2108,10 @@ class Libzot {
// back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing
// this information from the metadata should have no other discernible impact.
- if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) {
+ if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) {
q("update item set item_origin = 0 where id = %d and uid = %d",
- intval($r[0]['id']),
- intval($r[0]['uid'])
+ intval($stored['id']),
+ intval($stored['uid'])
);
}
}
diff --git a/include/zot.php b/include/zot.php
index 9dd9aceff..5fd900765 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2241,7 +2241,7 @@ function delete_imported_item($sender, $item, $uid, $relay) {
$item_found = false;
$post_id = 0;
- $r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
+ $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
and mid = '%s' and uid = %d limit 1",
dbesc($sender['hash']),
dbesc($sender['hash']),
@@ -2251,10 +2251,13 @@ function delete_imported_item($sender, $item, $uid, $relay) {
);
if($r) {
- if($r[0]['author_xchan'] === $sender['hash'] || $r[0]['owner_xchan'] === $sender['hash'] || $r[0]['source_xchan'] === $sender['hash'])
+
+ $stored = $r[0];
+
+ if($stored['author_xchan'] === $sender['hash'] || $stored['owner_xchan'] === $sender['hash'] || $stored['source_xchan'] === $sender['hash'])
$ownership_valid = true;
- $post_id = $r[0]['id'];
+ $post_id = $stored['id'];
$item_found = true;
}
else {
@@ -2278,15 +2281,15 @@ function delete_imported_item($sender, $item, $uid, $relay) {
return false;
}
- if ($item['obj_type'] == ACTIVITY_OBJ_EVENT) {
+ if ($stored['resource_type'] === 'event') {
$i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
- dbesc($item['uuid']),
+ dbesc($stored['resource_id']),
intval($uid)
);
if ($i) {
if ($i[0]['event_xchan'] === $sender['hash']) {
q("delete from event where event_hash = '%s' and uid = %d",
- dbesc($item['uuid']),
+ dbesc($stored['resource_id']),
intval($uid)
);
}
@@ -2300,7 +2303,7 @@ function delete_imported_item($sender, $item, $uid, $relay) {
require_once('include/items.php');
if($item_found) {
- if(intval($r[0]['item_deleted'])) {
+ if(intval($stored['item_deleted'])) {
logger('delete_imported_item: item was already deleted');
if(! $relay)
return false;
@@ -2312,10 +2315,10 @@ function delete_imported_item($sender, $item, $uid, $relay) {
// back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing
// this information from the metadata should have no other discernible impact.
- if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) {
+ if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) {
q("update item set item_origin = 0 where id = %d and uid = %d",
- intval($r[0]['id']),
- intval($r[0]['uid'])
+ intval($stored['id']),
+ intval($stored['uid'])
);
}
}