Move Temporal::convert() to DateTimeFormat::convert()

This commit is contained in:
Hypolite Petovan 2018-01-26 21:38:34 -05:00
parent b7a7355292
commit 5e7285b9ba
64 changed files with 568 additions and 551 deletions

View file

@ -15,8 +15,8 @@ use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba;
use DOMDocument;
use DOMXPath;
@ -144,7 +144,7 @@ class PortableContact
}
if (isset($entry->updated)) {
$updated = date(Temporal::MYSQL, strtotime($entry->updated));
$updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
}
if (isset($entry->network)) {
@ -315,7 +315,7 @@ class PortableContact
$contact = ["url" => $profile];
if ($gcontacts[0]["created"] <= NULL_DATE) {
$contact['created'] = Temporal::utcNow();
$contact['created'] = DateTimeFormat::utcNow();
}
if ($force) {
@ -338,7 +338,7 @@ class PortableContact
if ($server_url != "") {
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
if ($force) {
$fields = ['last_failure' => Temporal::utcNow()];
$fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
}
@ -412,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"] = Temporal::utcNow();
//$contact["last_contact"] = DateTimeFormat::utcNow();
$contact = array_merge($contact, $noscrape);
GContact::update($contact);
if (trim($noscrape["updated"]) != "") {
$fields = ['last_contact' => Temporal::utcNow()];
$fields = ['last_contact' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
@ -468,7 +468,7 @@ class PortableContact
}
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
$fields = ['last_failure' => Temporal::utcNow()];
$fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
@ -484,7 +484,7 @@ class PortableContact
$feedret = Network::curl($data["poll"]);
if (!$feedret["success"]) {
$fields = ['last_failure' => Temporal::utcNow()];
$fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
@ -533,7 +533,7 @@ class PortableContact
public static function updateNeeded($created, $updated, $last_failure, $last_contact)
{
$now = strtotime(Temporal::utcNow());
$now = strtotime(DateTimeFormat::utcNow());
if ($updated > $last_contact) {
$contact_time = strtotime($updated);
@ -922,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' => Temporal::utcNow()];
$fields = ['created' => DateTimeFormat::utcNow()];
$condition = ['nurl' => normalise_link($server_url)];
dba::update('gserver', $fields, $condition);
}
@ -969,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' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -985,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' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -1000,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' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
@ -1332,9 +1332,9 @@ class PortableContact
if ($failure) {
$last_contact = $orig_last_contact;
$last_failure = Temporal::utcNow();
$last_failure = DateTimeFormat::utcNow();
} else {
$last_contact = Temporal::utcNow();
$last_contact = DateTimeFormat::utcNow();
$last_failure = $orig_last_failure;
}
@ -1362,7 +1362,7 @@ class PortableContact
dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
} elseif (!$failure) {
$fields['nurl'] = normalise_link($server_url);
$fields['created'] = Temporal::utcNow();
$fields['created'] = DateTimeFormat::utcNow();
dba::insert('gserver', $fields);
}
logger("End discovery for server " . $server_url, LOGGER_DEBUG);
@ -1507,7 +1507,7 @@ class PortableContact
$timeframe = 30;
}
$updatedSince = date(Temporal::MYSQL, time() - $timeframe * 86400);
$updatedSince = date(DateTimeFormat::MYSQL, time() - $timeframe * 86400);
// Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3)
$url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
@ -1526,7 +1526,7 @@ class PortableContact
}
}
$fields = ['last_poco_query' => Temporal::utcNow()];
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return true;
@ -1535,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' => Temporal::utcNow()];
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return false;
@ -1561,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' => Temporal::utcNow()];
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
continue;
}
@ -1654,7 +1654,7 @@ class PortableContact
}
if (isset($entry->updated)) {
$updated = date(Temporal::MYSQL, strtotime($entry->updated));
$updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
}
if (isset($entry->network)) {