unmark for archival

This commit is contained in:
Michael 2017-12-04 19:36:08 +00:00
parent 3bb53967f4
commit 360e39ca5b
2 changed files with 5 additions and 7 deletions

View file

@ -1151,6 +1151,10 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
* @param array $arr Contains the just posted item record * @param array $arr Contains the just posted item record
*/ */
function item_set_last_item($arr) { function item_set_last_item($arr) {
$contact = dba::select('contact', [], ['id' => $arr['contact-id']], ['limit' => 1]);
if ($contact['term-date'] > NULL_DATE) {
Contact::unmarkForArchival($contact);
}
$update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"]))); $update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"])));
@ -1166,10 +1170,6 @@ function item_set_last_item($arr) {
if ($update) { if ($update) {
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']), dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
array('id' => $arr['contact-id'])); array('id' => $arr['contact-id']));
$contact = dba::select('contact', [], ['id' => $arr['contact-id']], ['limit' => 1]);
if ($contact['term-date'] > NULL_DATE) {
Contact::unmarkForArchival($contact);
}
} }
// Now do the same for the system wide contacts with uid=0 // Now do the same for the system wide contacts with uid=0
if (!$arr['private']) { if (!$arr['private']) {

View file

@ -145,7 +145,6 @@ class Contact extends BaseObject
if ($contact['archive']) { if ($contact['archive']) {
return; return;
} }
logger('Blubb-m: '.$contact['id'].' - '.System::callstack());
if ($contact['term-date'] <= NULL_DATE) { if ($contact['term-date'] <= NULL_DATE) {
dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id'])); dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id']));
@ -185,8 +184,7 @@ logger('Blubb-m: '.$contact['id'].' - '.System::callstack());
*/ */
public static function unmarkForArchival(array $contact) public static function unmarkForArchival(array $contact)
{ {
//logger('Blubb-m: '.$contact['id'].' - '.System::callstack()); $condition = array('`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], NULL_DATE);
$condition = array('`id` = ? AND (`term-date` > ? OR `archive`)', $contact[`id`], NULL_DATE);
$exists = dba::exists('contact', $condition); $exists = dba::exists('contact', $condition);
// We don't need to update, we never marked this contact for archival // We don't need to update, we never marked this contact for archival