mirror of
https://github.com/friendica/friendica
synced 2025-04-29 10:24:23 +02:00
Merge pull request #5452 from MrPetovan/bug/5443-fix-worker-notices
Fix notices in OEmbed et al.
This commit is contained in:
commit
5a8654194a
5 changed files with 169 additions and 109 deletions
|
@ -1647,27 +1647,33 @@ class PortableContact
|
|||
|
||||
$no_of_queries = 5;
|
||||
|
||||
$requery_days = intval(Config::get("system", "poco_requery_days"));
|
||||
$requery_days = intval(Config::get('system', 'poco_requery_days'));
|
||||
|
||||
if ($requery_days == 0) {
|
||||
$requery_days = 7;
|
||||
}
|
||||
$last_update = date("c", time() - (60 * 60 * 24 * $requery_days));
|
||||
$last_update = date('c', time() - (60 * 60 * 24 * $requery_days));
|
||||
|
||||
$r = q("SELECT `id`, `url`, `nurl`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", DBA::escape($last_update));
|
||||
if (DBA::isResult($r)) {
|
||||
foreach ($r as $server) {
|
||||
if (!self::checkServer($server["url"], $server["network"])) {
|
||||
$gservers = q("SELECT `id`, `url`, `nurl`, `network`
|
||||
FROM `gserver`
|
||||
WHERE `last_contact` >= `last_failure`
|
||||
AND `poco` != ''
|
||||
AND `last_poco_query` < '%s'
|
||||
ORDER BY RAND()", DBA::escape($last_update)
|
||||
);
|
||||
if (DBA::isResult($gservers)) {
|
||||
foreach ($gservers as $gserver) {
|
||||
if (!self::checkServer($gserver['url'], $gserver['network'])) {
|
||||
// The server is not reachable? Okay, then we will try it later
|
||||
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
|
||||
DBA::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
DBA::update('gserver', $fields, ['nurl' => $gserver['nurl']]);
|
||||
continue;
|
||||
}
|
||||
|
||||
logger('Update directory from server '.$server['url'].' with ID '.$server['id'], LOGGER_DEBUG);
|
||||
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "update_server_directory", (int)$server['id']);
|
||||
logger('Update directory from server ' . $gserver['url'] . ' with ID ' . $gserver['id'], LOGGER_DEBUG);
|
||||
Worker::add(PRIORITY_LOW, 'DiscoverPoCo', 'update_server_directory', (int) $gserver['id']);
|
||||
|
||||
if (!$complete && (--$no_of_queries == 0)) {
|
||||
if (!$complete && ( --$no_of_queries == 0)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1681,25 +1687,25 @@ class PortableContact
|
|||
}
|
||||
|
||||
foreach ($data->entry as $entry) {
|
||||
$username = "";
|
||||
$username = '';
|
||||
if (isset($entry->urls)) {
|
||||
foreach ($entry->urls as $url) {
|
||||
if ($url->type == 'profile') {
|
||||
$profile_url = $url->value;
|
||||
$urlparts = parse_url($profile_url);
|
||||
$username = end(explode("/", $urlparts["path"]));
|
||||
$path_array = explode('/', parse_url($profile_url, PHP_URL_PATH));
|
||||
$username = end($path_array);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($username != "") {
|
||||
logger("Fetch contacts for the user ".$username." from the server ".$server["nurl"], LOGGER_DEBUG);
|
||||
if ($username != '') {
|
||||
logger('Fetch contacts for the user ' . $username . ' from the server ' . $server['nurl'], LOGGER_DEBUG);
|
||||
|
||||
// Fetch all contacts from a given user from the other server
|
||||
$url = $server["poco"]."/".$username."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
|
||||
$url = $server['poco'] . '/' . $username . '/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation';
|
||||
|
||||
$retdata = Network::curl($url);
|
||||
if ($retdata["success"]) {
|
||||
self::discoverServer(json_decode($retdata["body"]), 3);
|
||||
if ($retdata['success']) {
|
||||
self::discoverServer(json_decode($retdata['body']), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue