Merge pull request #5060 from annando/item-delete

item deletion now works again
pull/5064/head
Hypolite Petovan 2018-05-15 23:56:23 -04:00 zatwierdzone przez GitHub
commit c3a532a9f6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
7 zmienionych plików z 62 dodań i 46 usunięć

Wyświetl plik

@ -433,7 +433,6 @@ These Fields are not added below (yet). They are here to for bug search.
`item`.`bookmark`,
`item`.`unseen`,
`item`.`deleted`,
`item`.`origin`,
`item`.`forum_mode`,
`item`.`mention`,
`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`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
`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`.`location`, `item`.`coord`, `item`.`app`, `item`.`attach`,
`item`.`rendered-hash`, `item`.`rendered-html`, `item`.`object`,

Wyświetl plik

@ -112,15 +112,17 @@ class Item extends BaseObject
public static function deleteById($item_id, $priority = PRIORITY_HIGH)
{
// locate item to be deleted
$fields = ['id', 'uid', 'parent', 'parent-uri', 'origin', 'deleted',
'file', 'resource-id', 'event-id', 'attach',
$fields = ['id', 'uri', 'uid', 'parent', 'parent-uri', 'origin',
'deleted', 'file', 'resource-id', 'event-id', 'attach',
'verb', 'object-type', 'object', 'target', 'contact-id'];
$item = dba::selectFirst('item', $fields, ['id' => $item_id]);
if (!DBM::is_result($item)) {
logger('Item with ID ' . $item_id . " hasn't been found.", LOGGER_DEBUG);
return false;
}
if ($item['deleted']) {
logger('Item with ID ' . $item_id . ' has already been deleted.', LOGGER_DEBUG);
return false;
}
@ -129,8 +131,6 @@ class Item extends BaseObject
$parent = ['origin' => false];
}
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
// clean up categories and tags so they don't end up as orphans
$matches = false;
@ -183,16 +183,27 @@ class Item extends BaseObject
Term::insertFromFileFieldByItemId($item['id']);
self::deleteThread($item['id'], $item['parent-uri']);
// If it's the parent of a comment thread, kill all the kids
if ($item['id'] == $item['parent']) {
self::delete(['parent' => $item['parent']], $priority);
if (!dba::exists('item', ["`uri` = ? AND `uid` != 0 AND NOT `deleted`", $item['uri']])) {
self::delete(['uri' => $item['uri'], 'uid' => 0, 'deleted' => false], $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']) {
// 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']));
}
logger('Item with ID ' . $item_id . " has been deleted.", LOGGER_DEBUG);
return true;
}
@ -333,6 +344,12 @@ class Item extends BaseObject
$item['origin'] = 1;
$item['network'] = NETWORK_DFRN;
$item['protocol'] = PROTOCOL_DFRN;
if (is_int($notify)) {
$priority = $notify;
} else {
$priority = PRIORITY_HIGH;
}
} else {
$item['network'] = trim(defaults($item, 'network', NETWORK_PHANTOM));
}
@ -861,7 +878,7 @@ class Item extends BaseObject
check_user_notification($current_post);
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']) {
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", "comment-import", $current_post);
}

Wyświetl plik

@ -172,13 +172,31 @@ class Post extends BaseObject
$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 = [
'dropping' => $dropping,
'pagedrop' => ((Feature::isEnabled($conv->getProfileOwner(), 'multi_delete')) ? $item['pagedrop'] : ''),
'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);
$diff_author = !link_compare($item['url'], $item['author-link']);

Wyświetl plik

@ -2719,23 +2719,6 @@ class DFRN
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;
}
} else { // $entrytype == DFRN::TOP_LEVEL
@ -2837,14 +2820,6 @@ class DFRN
}
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"]);
}
}
}
/**

Wyświetl plik

@ -2868,12 +2868,6 @@ class Diaspora
Item::deleteById($item["id"]);
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;

Wyświetl plik

@ -430,6 +430,9 @@ class Feed {
$item['guid'] = Item::guidFromUri($orig_plink, $a->get_hostname());
unset($item['uri']);
unset($item['parent-uri']);
// Set the delivery priority for "remote self" to "medium"
$notify = PRIORITY_MEDIUM;
}
$id = Item::insert($item, false, $notify);

Wyświetl plik

@ -74,6 +74,7 @@ Class Cron {
$d1 = Config::get('system', 'last_expire_day');
$d2 = intval(DateTimeFormat::utcNow('d'));
// Daily cron calls
if ($d2 != intval($d1)) {
Worker::add(PRIORITY_LOW, "CronJobs", "update_contact_birthdays");
@ -90,13 +91,22 @@ Class Cron {
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?
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
self::pollContacts($parameter, $generation);