*/
public static function markForArchival(array $contact)
{
- if (!isset($contact['url']) && !empty($contact['id'])) {
- $fields = ['id', 'url', 'archive', 'self', 'term-date'];
+ if ((!isset($contact['url']) || !isset($contact['uri-id'])) && !empty($contact['id'])) {
+ $fields = ['id', 'uri-id', 'url', 'archive', 'self', 'term-date'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $contact['id']]);
if (!DBA::isResult($contact)) {
return;
}
- } elseif (!isset($contact['url'])) {
+ } elseif (!isset($contact['url']) || !isset($contact['uri-id'])) {
Logger::info('Empty contact', ['contact' => $contact]);
}
- Logger::info('Contact is marked for archival', ['id' => $contact['id'], 'term-date' => $contact['term-date']]);
+ Logger::info('Contact is marked for archival', ['id' => $contact['id'], 'archive' => $contact['archive'], 'term-date' => $contact['term-date'], 'url' => $contact['url']]);
// Contact already archived or "self" contact? => nothing to do
if ($contact['archive'] || $contact['self']) {
}
if ($contact['term-date'] <= DBA::NULL_DATETIME) {
- self::update(['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
- self::update(['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', Strings::normaliseLink($contact['url']), DBA::NULL_DATETIME]);
+ self::update(['term-date' => DateTimeFormat::utcNow()], ['uri-id' => $contact['uri-id'], 'self' => false]);
} else {
/* @todo
* We really should send a notification to the owner after 2-3 weeks
* delete, though if the owner tries to unarchive them we'll start
* the whole process over again.
*/
- self::update(['archive' => true], ['id' => $contact['id']]);
- self::update(['archive' => true], ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
+ self::update(['archive' => true], ['uri-id' => $contact['uri-id'], 'self' => false]);
}
}
}
}
}
- $condition = ['`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], DBA::NULL_DATETIME];
- $exists = DBA::exists('contact', $condition);
-
// We don't need to update, we never marked this contact for archival
- if (!$exists) {
+ $condition = ['`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], DBA::NULL_DATETIME];
+ if (!DBA::exists('contact', $condition)) {
return;
}
- Logger::info('Contact is marked as vital again', ['id' => $contact['id'], 'term-date' => $contact['term-date']]);
-
- if (!isset($contact['url']) && !empty($contact['id'])) {
- $fields = ['id', 'url', 'batch'];
+ if ((!isset($contact['url']) || !isset($contact['uri-id'])) && !empty($contact['id'])) {
+ $fields = ['id', 'uri-id', 'url', 'batch', 'term-date'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $contact['id']]);
if (!DBA::isResult($contact)) {
return;
}
}
+ Logger::info('Contact is marked as vital again', ['id' => $contact['id'], 'term-date' => $contact['term-date'], 'url' => $contact['url']]);
+
// It's a miracle. Our dead contact has inexplicably come back to life.
$fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
- self::update($fields, ['id' => $contact['id']]);
- self::update($fields, ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
+ self::update($fields, ['uri-id' => $contact['uri-id'], 'self' => false]);
}
/**