Merge pull request #5060 from annando/item-delete
item deletion now works again
This commit is contained in:
commit
c3a532a9f6
7 changed files with 62 additions and 46 deletions
|
@ -433,7 +433,6 @@ These Fields are not added below (yet). They are here to for bug search.
|
||||||
`item`.`bookmark`,
|
`item`.`bookmark`,
|
||||||
`item`.`unseen`,
|
`item`.`unseen`,
|
||||||
`item`.`deleted`,
|
`item`.`deleted`,
|
||||||
`item`.`origin`,
|
|
||||||
`item`.`forum_mode`,
|
`item`.`forum_mode`,
|
||||||
`item`.`mention`,
|
`item`.`mention`,
|
||||||
`item`.`global`,
|
`item`.`global`,
|
||||||
|
@ -446,7 +445,7 @@ These Fields are not added below (yet). They are here to for bug search.
|
||||||
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`content-warning`,
|
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`content-warning`,
|
||||||
`item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
|
`item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
|
||||||
`item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`,
|
`item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`,
|
||||||
`item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`,
|
`item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`, `item`.`origin`,
|
||||||
`item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`,
|
`item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`,
|
||||||
`item`.`location`, `item`.`coord`, `item`.`app`, `item`.`attach`,
|
`item`.`location`, `item`.`coord`, `item`.`app`, `item`.`attach`,
|
||||||
`item`.`rendered-hash`, `item`.`rendered-html`, `item`.`object`,
|
`item`.`rendered-hash`, `item`.`rendered-html`, `item`.`object`,
|
||||||
|
|
|
@ -112,15 +112,17 @@ class Item extends BaseObject
|
||||||
public static function deleteById($item_id, $priority = PRIORITY_HIGH)
|
public static function deleteById($item_id, $priority = PRIORITY_HIGH)
|
||||||
{
|
{
|
||||||
// locate item to be deleted
|
// locate item to be deleted
|
||||||
$fields = ['id', 'uid', 'parent', 'parent-uri', 'origin', 'deleted',
|
$fields = ['id', 'uri', 'uid', 'parent', 'parent-uri', 'origin',
|
||||||
'file', 'resource-id', 'event-id', 'attach',
|
'deleted', 'file', 'resource-id', 'event-id', 'attach',
|
||||||
'verb', 'object-type', 'object', 'target', 'contact-id'];
|
'verb', 'object-type', 'object', 'target', 'contact-id'];
|
||||||
$item = dba::selectFirst('item', $fields, ['id' => $item_id]);
|
$item = dba::selectFirst('item', $fields, ['id' => $item_id]);
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBM::is_result($item)) {
|
||||||
|
logger('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['deleted']) {
|
if ($item['deleted']) {
|
||||||
|
logger('Item with ID ' . $item_id . ' has already been deleted.', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +131,6 @@ class Item extends BaseObject
|
||||||
$parent = ['origin' => false];
|
$parent = ['origin' => false];
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
|
|
||||||
|
|
||||||
// clean up categories and tags so they don't end up as orphans
|
// clean up categories and tags so they don't end up as orphans
|
||||||
|
|
||||||
$matches = false;
|
$matches = false;
|
||||||
|
@ -183,16 +183,27 @@ class Item extends BaseObject
|
||||||
Term::insertFromFileFieldByItemId($item['id']);
|
Term::insertFromFileFieldByItemId($item['id']);
|
||||||
self::deleteThread($item['id'], $item['parent-uri']);
|
self::deleteThread($item['id'], $item['parent-uri']);
|
||||||
|
|
||||||
// If it's the parent of a comment thread, kill all the kids
|
if (!dba::exists('item', ["`uri` = ? AND `uid` != 0 AND NOT `deleted`", $item['uri']])) {
|
||||||
if ($item['id'] == $item['parent']) {
|
self::delete(['uri' => $item['uri'], 'uid' => 0, 'deleted' => false], $priority);
|
||||||
self::delete(['parent' => $item['parent']], $priority);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the notification upstream/downstream
|
// If it's the parent of a comment thread, kill all the kids
|
||||||
|
if ($item['id'] == $item['parent']) {
|
||||||
|
self::delete(['parent' => $item['parent'], 'deleted' => false], $priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is it our comment and/or our thread?
|
||||||
if ($item['origin'] || $parent['origin']) {
|
if ($item['origin'] || $parent['origin']) {
|
||||||
|
|
||||||
|
// When we delete the original post we will delete all existing copies on the server as well
|
||||||
|
self::delete(['uri' => $item['uri'], 'deleted' => false], $priority);
|
||||||
|
|
||||||
|
// send the notification upstream/downstream
|
||||||
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", intval($item['id']));
|
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", intval($item['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger('Item with ID ' . $item_id . " has been deleted.", LOGGER_DEBUG);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +344,12 @@ class Item extends BaseObject
|
||||||
$item['origin'] = 1;
|
$item['origin'] = 1;
|
||||||
$item['network'] = NETWORK_DFRN;
|
$item['network'] = NETWORK_DFRN;
|
||||||
$item['protocol'] = PROTOCOL_DFRN;
|
$item['protocol'] = PROTOCOL_DFRN;
|
||||||
|
|
||||||
|
if (is_int($notify)) {
|
||||||
|
$priority = $notify;
|
||||||
|
} else {
|
||||||
|
$priority = PRIORITY_HIGH;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$item['network'] = trim(defaults($item, 'network', NETWORK_PHANTOM));
|
$item['network'] = trim(defaults($item, 'network', NETWORK_PHANTOM));
|
||||||
}
|
}
|
||||||
|
@ -861,7 +878,7 @@ class Item extends BaseObject
|
||||||
check_user_notification($current_post);
|
check_user_notification($current_post);
|
||||||
|
|
||||||
if ($notify) {
|
if ($notify) {
|
||||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", $notify_type, $current_post);
|
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", $notify_type, $current_post);
|
||||||
} elseif (!empty($parent) && $parent['origin']) {
|
} elseif (!empty($parent) && $parent['origin']) {
|
||||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", "comment-import", $current_post);
|
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", "comment-import", $current_post);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,13 +172,31 @@ class Post extends BaseObject
|
||||||
$dropping = true;
|
$dropping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$origin = $item['origin'];
|
||||||
|
|
||||||
|
if (!$origin) {
|
||||||
|
/// @todo This shouldn't be done as query here, but better during the data creation.
|
||||||
|
// it is now done here, since during the RC phase we shouldn't make to intense changes.
|
||||||
|
$parent = dba::selectFirst('item', ['origin'], ['id' => $item['parent']]);
|
||||||
|
if (DBM::is_result($parent)) {
|
||||||
|
$origin = $parent['origin'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Showing the one or the other text, depending upon if we can only hide it or really delete it.
|
||||||
|
$delete = $origin ? L10n::t('Delete') : L10n::t('Remove from your stream');
|
||||||
|
|
||||||
$drop = [
|
$drop = [
|
||||||
'dropping' => $dropping,
|
'dropping' => $dropping,
|
||||||
'pagedrop' => ((Feature::isEnabled($conv->getProfileOwner(), 'multi_delete')) ? $item['pagedrop'] : ''),
|
'pagedrop' => ((Feature::isEnabled($conv->getProfileOwner(), 'multi_delete')) ? $item['pagedrop'] : ''),
|
||||||
'select' => L10n::t('Select'),
|
'select' => L10n::t('Select'),
|
||||||
'delete' => L10n::t('Remove from your stream'),
|
'delete' => $delete,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (!local_user()) {
|
||||||
|
$drop = false;
|
||||||
|
}
|
||||||
|
|
||||||
$filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false);
|
$filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false);
|
||||||
|
|
||||||
$diff_author = !link_compare($item['url'], $item['author-link']);
|
$diff_author = !link_compare($item['url'], $item['author-link']);
|
||||||
|
|
|
@ -2719,23 +2719,6 @@ class DFRN
|
||||||
Item::distribute($posted_id);
|
Item::distribute($posted_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item["id"] = $posted_id;
|
|
||||||
|
|
||||||
$r = q(
|
|
||||||
"SELECT `parent`, `parent-uri` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
|
||||||
intval($posted_id),
|
|
||||||
intval($importer["importer_uid"])
|
|
||||||
);
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
$parent = $r[0]["parent"];
|
|
||||||
$parent_uri = $r[0]["parent-uri"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($posted_id && $parent && ($entrytype == DFRN::REPLY_RC)) {
|
|
||||||
logger("Notifying followers about comment ".$posted_id, LOGGER_DEBUG);
|
|
||||||
Worker::add(PRIORITY_HIGH, "Notifier", "comment-import", $posted_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else { // $entrytype == DFRN::TOP_LEVEL
|
} else { // $entrytype == DFRN::TOP_LEVEL
|
||||||
|
@ -2837,14 +2820,6 @@ class DFRN
|
||||||
}
|
}
|
||||||
|
|
||||||
Item::deleteById($item["id"]);
|
Item::deleteById($item["id"]);
|
||||||
|
|
||||||
if ($entrytype != DFRN::TOP_LEVEL) {
|
|
||||||
// if this is a relayed delete, propagate it to other recipients
|
|
||||||
if ($entrytype == DFRN::REPLY_RC) {
|
|
||||||
logger("Notifying followers about deletion of post " . $item["id"], LOGGER_DEBUG);
|
|
||||||
Worker::add(PRIORITY_HIGH, "Notifier", "drop", $item["id"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2868,12 +2868,6 @@ class Diaspora
|
||||||
Item::deleteById($item["id"]);
|
Item::deleteById($item["id"]);
|
||||||
|
|
||||||
logger("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], LOGGER_DEBUG);
|
logger("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], LOGGER_DEBUG);
|
||||||
|
|
||||||
// Now check if the retraction needs to be relayed by us
|
|
||||||
if ($parent["origin"]) {
|
|
||||||
// notify others
|
|
||||||
Worker::add(PRIORITY_HIGH, "Notifier", "drop", $item["id"]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -430,6 +430,9 @@ class Feed {
|
||||||
$item['guid'] = Item::guidFromUri($orig_plink, $a->get_hostname());
|
$item['guid'] = Item::guidFromUri($orig_plink, $a->get_hostname());
|
||||||
unset($item['uri']);
|
unset($item['uri']);
|
||||||
unset($item['parent-uri']);
|
unset($item['parent-uri']);
|
||||||
|
|
||||||
|
// Set the delivery priority for "remote self" to "medium"
|
||||||
|
$notify = PRIORITY_MEDIUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = Item::insert($item, false, $notify);
|
$id = Item::insert($item, false, $notify);
|
||||||
|
|
|
@ -74,6 +74,7 @@ Class Cron {
|
||||||
$d1 = Config::get('system', 'last_expire_day');
|
$d1 = Config::get('system', 'last_expire_day');
|
||||||
$d2 = intval(DateTimeFormat::utcNow('d'));
|
$d2 = intval(DateTimeFormat::utcNow('d'));
|
||||||
|
|
||||||
|
// Daily cron calls
|
||||||
if ($d2 != intval($d1)) {
|
if ($d2 != intval($d1)) {
|
||||||
|
|
||||||
Worker::add(PRIORITY_LOW, "CronJobs", "update_contact_birthdays");
|
Worker::add(PRIORITY_LOW, "CronJobs", "update_contact_birthdays");
|
||||||
|
@ -90,13 +91,22 @@ Class Cron {
|
||||||
|
|
||||||
Worker::add(PRIORITY_LOW, "CronJobs", "update_photo_albums");
|
Worker::add(PRIORITY_LOW, "CronJobs", "update_photo_albums");
|
||||||
|
|
||||||
// Delete all done workerqueue entries
|
|
||||||
dba::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 12 HOUR']);
|
|
||||||
|
|
||||||
// check upstream version?
|
// check upstream version?
|
||||||
Worker::add(PRIORITY_LOW, 'CheckVersion');
|
Worker::add(PRIORITY_LOW, 'CheckVersion');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hourly cron calls
|
||||||
|
if (Config::get('system', 'last_cron_hourly', 0) + 3600 < time()) {
|
||||||
|
|
||||||
|
// Delete all done workerqueue entries
|
||||||
|
dba::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 1 HOUR']);
|
||||||
|
|
||||||
|
// Optimizing this table only last seconds
|
||||||
|
dba::e("OPTIMIZE TABLE `workerqueue`");
|
||||||
|
|
||||||
|
Config::set('system', 'last_cron_hourly', time());
|
||||||
|
}
|
||||||
|
|
||||||
// Poll contacts
|
// Poll contacts
|
||||||
self::pollContacts($parameter, $generation);
|
self::pollContacts($parameter, $generation);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue