mirror of
https://github.com/friendica/friendica
synced 2025-04-27 13:50:12 +00:00
Refactor datetime_convert into Temporal::convert
- Changed parameter order to save space - Refactor select_timezone into Temporal::getTimezoneSelect - Refactor field_timezone into Temporal::getTimezoneField
This commit is contained in:
parent
d478ef6c6d
commit
dc366bf1f7
62 changed files with 512 additions and 432 deletions
|
@ -14,6 +14,7 @@ use Friendica\Protocol\Email;
|
|||
use Friendica\Protocol\PortableContact;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\XML;
|
||||
use Friendica\Util\Temporal;
|
||||
use dba;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
@ -43,7 +44,7 @@ class OnePoll
|
|||
return;
|
||||
}
|
||||
|
||||
$d = datetime_convert();
|
||||
$d = Temporal::convert();
|
||||
|
||||
$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
|
||||
if (!DBM::is_result($contact)) {
|
||||
|
@ -69,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 = datetime_convert();
|
||||
$updated = Temporal::convert();
|
||||
if ($last_updated) {
|
||||
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
||||
|
||||
|
@ -98,7 +99,7 @@ class OnePoll
|
|||
$contact['priority'] = intval($poll_interval);
|
||||
$hub_update = false;
|
||||
|
||||
if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day")) {
|
||||
if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) {
|
||||
$hub_update = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -106,8 +107,8 @@ class OnePoll
|
|||
}
|
||||
|
||||
$last_update = (($contact['last-update'] <= NULL_DATE)
|
||||
? datetime_convert('UTC', 'UTC', 'now - 7 days', ATOM_TIME)
|
||||
: datetime_convert('UTC', 'UTC', $contact['last-update'], ATOM_TIME)
|
||||
? Temporal::convert('now - 7 days', 'UTC', 'UTC', ATOM_TIME)
|
||||
: Temporal::convert($contact['last-update'], 'UTC', 'UTC', ATOM_TIME)
|
||||
);
|
||||
|
||||
// Update the contact entry
|
||||
|
@ -116,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -125,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
return;
|
||||
} else {
|
||||
Contact::unmarkForArchival($contact);
|
||||
|
@ -136,7 +137,7 @@ class OnePoll
|
|||
logger('Ignore public contacts');
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -184,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +207,7 @@ class OnePoll
|
|||
Contact::markForArchival($contact);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
$fields = ['last-update' => datetime_convert(), 'failure_update' => datetime_convert()];
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
self::updateContact($contact, $fields);
|
||||
return;
|
||||
}
|
||||
|
@ -216,7 +217,7 @@ class OnePoll
|
|||
|
||||
Contact::markForArchival($contact);
|
||||
|
||||
$fields = ['last-update' => datetime_convert(), 'failure_update' => datetime_convert()];
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
self::updateContact($contact, $fields);
|
||||
return;
|
||||
}
|
||||
|
@ -229,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' => datetime_convert(), 'failure_update' => datetime_convert()];
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
self::updateContact($contact, $fields);
|
||||
|
||||
Contact::markForArchival($contact);
|
||||
|
@ -240,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
@ -310,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -320,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
@ -334,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' => datetime_convert()], ['id' => $contact['id']]);
|
||||
dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
}
|
||||
|
@ -354,7 +355,7 @@ class OnePoll
|
|||
unset($password);
|
||||
logger("Mail: Connect to " . $mailconf['user']);
|
||||
if ($mbox) {
|
||||
$fields = ['last_check' => datetime_convert()];
|
||||
$fields = ['last_check' => Temporal::convert()];
|
||||
dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
|
||||
logger("Mail: Connected to " . $mailconf['user']);
|
||||
} else {
|
||||
|
@ -394,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' => datetime_convert()];
|
||||
$fields = ['deleted' => true, 'changed' => Temporal::convert()];
|
||||
dba::update('item', $fields, ['id' => $item['id']]);
|
||||
}
|
||||
|
||||
|
@ -458,7 +459,7 @@ class OnePoll
|
|||
$datarray['title'] = notags(trim($datarray['title']));
|
||||
|
||||
//$datarray['title'] = notags(trim($meta->subject));
|
||||
$datarray['created'] = datetime_convert('UTC', 'UTC', $meta->date);
|
||||
$datarray['created'] = Temporal::convert($meta->date);
|
||||
|
||||
// Is it a reply?
|
||||
$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") ||
|
||||
|
@ -571,7 +572,7 @@ class OnePoll
|
|||
if (!strstr($xml, '<')) {
|
||||
logger('post_handshake: response from ' . $url . ' did not contain XML.');
|
||||
|
||||
$fields = ['last-update' => datetime_convert(), 'failure_update' => datetime_convert()];
|
||||
$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
|
||||
self::updateContact($contact, $fields);
|
||||
Contact::markForArchival($contact);
|
||||
return;
|
||||
|
@ -615,19 +616,19 @@ class OnePoll
|
|||
}
|
||||
}
|
||||
|
||||
$updated = datetime_convert();
|
||||
$updated = Temporal::convert();
|
||||
|
||||
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 = datetime_convert();
|
||||
$updated = Temporal::convert();
|
||||
|
||||
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
|
||||
dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
|
||||
Contact::markForArchival($contact);
|
||||
} else {
|
||||
$updated = datetime_convert();
|
||||
$updated = Temporal::convert();
|
||||
dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue