Add Temporal::utcNow()
This commit is contained in:
parent
38ff1b455b
commit
8aff8a76eb
51 changed files with 191 additions and 180 deletions
|
|
@ -71,7 +71,7 @@ Class Cron {
|
|||
|
||||
// once daily run birthday_updates and then expire in background
|
||||
$d1 = Config::get('system', 'last_expire_day');
|
||||
$d2 = intval(Temporal::convert('now', 'UTC', 'UTC', 'd'));
|
||||
$d2 = intval(Temporal::utcNow('d'));
|
||||
|
||||
if ($d2 != intval($d1)) {
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ Class Cron {
|
|||
|
||||
Addon::reload();
|
||||
|
||||
$d = Temporal::convert();
|
||||
$d = Temporal::utcNow();
|
||||
|
||||
// Only poll from those with suitable relationships,
|
||||
// and which have a polling address and ignore Diaspora since
|
||||
|
|
@ -218,33 +218,33 @@ Class Cron {
|
|||
*/
|
||||
switch ($contact['priority']) {
|
||||
case 5:
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + 1 month")) {
|
||||
if (Temporal::utcNow() > Temporal::convert($t . " + 1 month")) {
|
||||
$update = true;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + 1 week")) {
|
||||
if (Temporal::utcNow() > Temporal::convert($t . " + 1 week")) {
|
||||
$update = true;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) {
|
||||
if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) {
|
||||
$update = true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + 12 hour")) {
|
||||
if (Temporal::utcNow() > Temporal::convert($t . " + 12 hour")) {
|
||||
$update = true;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + 1 hour")) {
|
||||
if (Temporal::utcNow() > Temporal::convert($t . " + 1 hour")) {
|
||||
$update = true;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + ".$min_poll_interval." minute")) {
|
||||
if (Temporal::utcNow() > Temporal::convert($t . " + ".$min_poll_interval." minute")) {
|
||||
$update = true;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Class CronHooks {
|
|||
|
||||
logger('cronhooks: start');
|
||||
|
||||
$d = Temporal::convert();
|
||||
$d = Temporal::utcNow();
|
||||
|
||||
if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
|
||||
foreach ($a->hooks["cron"] as $hook) {
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class DiscoverPoCo {
|
|||
}
|
||||
} else {
|
||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
||||
dbesc(Temporal::convert()), dbesc(normalise_link($user["url"])));
|
||||
dbesc(Temporal::utcNow()), dbesc(normalise_link($user["url"])));
|
||||
}
|
||||
|
||||
// Quit the loop after 3 minutes
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class OnePoll
|
|||
return;
|
||||
}
|
||||
|
||||
$d = Temporal::convert();
|
||||
$d = Temporal::utcNow();
|
||||
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
|
|
@ -70,7 +70,7 @@ class OnePoll
|
|||
// Diaspora users, archived users and followers are only checked if they still exist.
|
||||
if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
||||
$last_updated = PortableContact::lastUpdated($contact["url"], true);
|
||||
$updated = Temporal::convert();
|
||||
$updated = Temporal::utcNow();
|
||||
if ($last_updated) {
|
||||
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ class OnePoll
|
|||
$contact['priority'] = intval($poll_interval);
|
||||
$hub_update = false;
|
||||
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) {
|
||||
if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) {
|
||||
$hub_update = true;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -117,7 +117,7 @@ class OnePoll
|
|||
logger("Skipping probably dead contact ".$contact['url']);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ class OnePoll
|
|||
logger('Contact is marked dead');
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
return;
|
||||
} else {
|
||||
Contact::unmarkForArchival($contact);
|
||||
|
|
@ -137,7 +137,7 @@ class OnePoll
|
|||
logger('Ignore public contacts');
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ class OnePoll
|
|||
logger('No self contact for user '.$importer_uid);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ class OnePoll
|
|||
|
||||
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
|
@ -207,7 +207,7 @@ class OnePoll
|
|||
Contact::markForArchival($contact);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
||||
self::updateContact($contact, $fields);
|
||||
return;
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ class OnePoll
|
|||
|
||||
Contact::markForArchival($contact);
|
||||
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
||||
self::updateContact($contact, $fields);
|
||||
return;
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ class OnePoll
|
|||
|
||||
// we may not be friends anymore. Will keep trying for one month.
|
||||
// set the last-update so we don't keep polling
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
||||
self::updateContact($contact, $fields);
|
||||
|
||||
Contact::markForArchival($contact);
|
||||
|
|
@ -241,7 +241,7 @@ class OnePoll
|
|||
|
||||
if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ class OnePoll
|
|||
logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ class OnePoll
|
|||
|
||||
if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) {
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ class OnePoll
|
|||
|
||||
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
|
@ -335,7 +335,7 @@ class OnePoll
|
|||
$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
|
||||
if ($mail_disabled) {
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ class OnePoll
|
|||
unset($password);
|
||||
logger("Mail: Connect to " . $mailconf['user']);
|
||||
if ($mbox) {
|
||||
$fields = ['last_check' => Temporal::convert()];
|
||||
$fields = ['last_check' => Temporal::utcNow()];
|
||||
dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
|
||||
logger("Mail: Connected to " . $mailconf['user']);
|
||||
} else {
|
||||
|
|
@ -395,7 +395,7 @@ class OnePoll
|
|||
// Only delete when mails aren't automatically moved or deleted
|
||||
if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
|
||||
if ($meta->deleted && ! $item['deleted']) {
|
||||
$fields = ['deleted' => true, 'changed' => Temporal::convert()];
|
||||
$fields = ['deleted' => true, 'changed' => Temporal::utcNow()];
|
||||
dba::update('item', $fields, ['id' => $item['id']]);
|
||||
}
|
||||
|
||||
|
|
@ -572,7 +572,7 @@ class OnePoll
|
|||
if (!strstr($xml, '<')) {
|
||||
logger('post_handshake: response from ' . $url . ' did not contain XML.');
|
||||
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
||||
self::updateContact($contact, $fields);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
|
|
@ -616,19 +616,19 @@ class OnePoll
|
|||
}
|
||||
}
|
||||
|
||||
$updated = Temporal::convert();
|
||||
$updated = Temporal::utcNow();
|
||||
|
||||
self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
|
||||
dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
|
||||
Contact::unmarkForArchival($contact);
|
||||
} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
|
||||
$updated = Temporal::convert();
|
||||
$updated = Temporal::utcNow();
|
||||
|
||||
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
|
||||
dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
|
||||
Contact::markForArchival($contact);
|
||||
} else {
|
||||
$updated = Temporal::convert();
|
||||
$updated = Temporal::utcNow();
|
||||
dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class UpdateGContact
|
|||
}
|
||||
|
||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
|
||||
dbesc(Temporal::convert()), intval($contact_id));
|
||||
dbesc(Temporal::utcNow()), intval($contact_id));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue