mirror of
https://github.com/friendica/friendica
synced 2025-04-25 15:50:10 +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
|
@ -16,6 +16,7 @@ use Friendica\Model\GContact;
|
|||
use Friendica\Model\Profile;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
|
@ -314,7 +315,7 @@ class PortableContact
|
|||
$contact = ["url" => $profile];
|
||||
|
||||
if ($gcontacts[0]["created"] <= NULL_DATE) {
|
||||
$contact['created'] = datetime_convert();
|
||||
$contact['created'] = Temporal::convert();
|
||||
}
|
||||
|
||||
if ($force) {
|
||||
|
@ -337,7 +338,7 @@ class PortableContact
|
|||
if ($server_url != "") {
|
||||
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
|
||||
if ($force) {
|
||||
$fields = ['last_failure' => datetime_convert()];
|
||||
$fields = ['last_failure' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
}
|
||||
|
||||
|
@ -411,14 +412,14 @@ class PortableContact
|
|||
|
||||
// Set the date of the last contact
|
||||
/// @todo By now the function "update_gcontact" doesn't work with this field
|
||||
//$contact["last_contact"] = datetime_convert();
|
||||
//$contact["last_contact"] = Temporal::convert();
|
||||
|
||||
$contact = array_merge($contact, $noscrape);
|
||||
|
||||
GContact::update($contact);
|
||||
|
||||
if (trim($noscrape["updated"]) != "") {
|
||||
$fields = ['last_contact' => datetime_convert()];
|
||||
$fields = ['last_contact' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
|
||||
|
@ -467,7 +468,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
|
||||
$fields = ['last_failure' => datetime_convert()];
|
||||
$fields = ['last_failure' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
|
||||
|
@ -483,7 +484,7 @@ class PortableContact
|
|||
$feedret = Network::curl($data["poll"]);
|
||||
|
||||
if (!$feedret["success"]) {
|
||||
$fields = ['last_failure' => datetime_convert()];
|
||||
$fields = ['last_failure' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
|
||||
|
@ -532,7 +533,7 @@ class PortableContact
|
|||
|
||||
public static function updateNeeded($created, $updated, $last_failure, $last_contact)
|
||||
{
|
||||
$now = strtotime(datetime_convert());
|
||||
$now = strtotime(Temporal::convert());
|
||||
|
||||
if ($updated > $last_contact) {
|
||||
$contact_time = strtotime($updated);
|
||||
|
@ -921,7 +922,7 @@ class PortableContact
|
|||
$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
|
||||
if (DBM::is_result($gserver)) {
|
||||
if ($gserver["created"] <= NULL_DATE) {
|
||||
$fields = ['created' => datetime_convert()];
|
||||
$fields = ['created' => Temporal::convert()];
|
||||
$condition = ['nurl' => normalise_link($server_url)];
|
||||
dba::update('gserver', $fields, $condition);
|
||||
}
|
||||
|
@ -968,7 +969,7 @@ class PortableContact
|
|||
// Mastodon uses the "@" for user profiles.
|
||||
// But this can be misunderstood.
|
||||
if (parse_url($server_url, PHP_URL_USER) != '') {
|
||||
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -984,7 +985,7 @@ class PortableContact
|
|||
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
|
||||
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -999,7 +1000,7 @@ class PortableContact
|
|||
// Quit if there is a timeout
|
||||
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1331,9 +1332,9 @@ class PortableContact
|
|||
|
||||
if ($failure) {
|
||||
$last_contact = $orig_last_contact;
|
||||
$last_failure = datetime_convert();
|
||||
$last_failure = Temporal::convert();
|
||||
} else {
|
||||
$last_contact = datetime_convert();
|
||||
$last_contact = Temporal::convert();
|
||||
$last_failure = $orig_last_failure;
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1362,7 @@ class PortableContact
|
|||
dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
|
||||
} elseif (!$failure) {
|
||||
$fields['nurl'] = normalise_link($server_url);
|
||||
$fields['created'] = datetime_convert();
|
||||
$fields['created'] = Temporal::convert();
|
||||
dba::insert('gserver', $fields);
|
||||
}
|
||||
logger("End discovery for server " . $server_url, LOGGER_DEBUG);
|
||||
|
@ -1525,7 +1526,7 @@ class PortableContact
|
|||
}
|
||||
}
|
||||
|
||||
$fields = ['last_poco_query' => datetime_convert()];
|
||||
$fields = ['last_poco_query' => Temporal::convert()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
|
||||
return true;
|
||||
|
@ -1534,7 +1535,7 @@ class PortableContact
|
|||
self::checkServer($server["url"], $server["network"], true);
|
||||
|
||||
// If we couldn't reach the server, we will try it some time later
|
||||
$fields = ['last_poco_query' => datetime_convert()];
|
||||
$fields = ['last_poco_query' => Temporal::convert()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
|
||||
return false;
|
||||
|
@ -1560,7 +1561,7 @@ class PortableContact
|
|||
foreach ($r as $server) {
|
||||
if (!self::checkServer($server["url"], $server["network"])) {
|
||||
// The server is not reachable? Okay, then we will try it later
|
||||
$fields = ['last_poco_query' => datetime_convert()];
|
||||
$fields = ['last_poco_query' => Temporal::convert()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue