Merge pull request #12360 from MrPetovan/bug/deprecated
Address several Deprecated messages
This commit is contained in:
commit
2722ef82cf
|
@ -631,10 +631,10 @@ class App
|
||||||
|
|
||||||
// ZRL
|
// ZRL
|
||||||
if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->session->getLocalUserId()) {
|
if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->session->getLocalUserId()) {
|
||||||
// Only continue when the given profile link seems valid
|
// Only continue when the given profile link seems valid.
|
||||||
// Valid profile links contain a path with "/profile/" and no query parameters
|
// Valid profile links contain a path with "/profile/" and no query parameters
|
||||||
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
|
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
|
||||||
strstr(parse_url($_GET['zrl'], PHP_URL_PATH), '/profile/')) {
|
strpos(parse_url($_GET['zrl'], PHP_URL_PATH) ?? '', '/profile/') !== false) {
|
||||||
if ($this->session->get('visitor_home') != $_GET['zrl']) {
|
if ($this->session->get('visitor_home') != $_GET['zrl']) {
|
||||||
$this->session->set('my_url', $_GET['zrl']);
|
$this->session->set('my_url', $_GET['zrl']);
|
||||||
$this->session->set('authenticated', 0);
|
$this->session->set('authenticated', 0);
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Avatar
|
||||||
|
|
||||||
private static function getFilename(string $url): string
|
private static function getFilename(string $url): string
|
||||||
{
|
{
|
||||||
$guid = Item::guidFromUri($url, parse_url($url, PHP_URL_HOST));
|
$guid = Item::guidFromUri($url);
|
||||||
|
|
||||||
return substr($guid, 0, 2) . '/' . substr($guid, 3, 2) . '/' . substr($guid, 5, 3) . '/' .
|
return substr($guid, 0, 2) . '/' . substr($guid, 3, 2) . '/' . substr($guid, 5, 3) . '/' .
|
||||||
substr($guid, 9, 2) .'/' . substr($guid, 11, 2) . '/' . substr($guid, 13, 4). '/' . substr($guid, 18) . '-';
|
substr($guid, 9, 2) .'/' . substr($guid, 11, 2) . '/' . substr($guid, 13, 4). '/' . substr($guid, 18) . '-';
|
||||||
|
|
|
@ -291,14 +291,11 @@ class APContact
|
||||||
return $fetched_contact;
|
return $fetched_contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = parse_url($apcontact['url']);
|
|
||||||
unset($parts['scheme']);
|
|
||||||
unset($parts['path']);
|
|
||||||
|
|
||||||
if (empty($apcontact['addr'])) {
|
if (empty($apcontact['addr'])) {
|
||||||
if (!empty($apcontact['nick']) && is_array($parts)) {
|
try {
|
||||||
$apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts));
|
$apcontact['addr'] = $apcontact['nick'] . '@' . (new Uri($apcontact['url']))->getAuthority();
|
||||||
} else {
|
} catch (\Throwable $e) {
|
||||||
|
Logger::warning('Unable to coerce APContact URL into a UriInterface object', ['url' => $apcontact['url'], 'error' => $e->getMessage()]);
|
||||||
$apcontact['addr'] = '';
|
$apcontact['addr'] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2099,7 +2099,7 @@ class Contact
|
||||||
if ($static) {
|
if ($static) {
|
||||||
$query_params['static'] = true;
|
$query_params['static'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url . ($guid ?: $cid) . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
|
return $url . ($guid ?: $cid) . (!empty($query_params) ? '?' . http_build_query($query_params) : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2675,7 +2675,7 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
$update = false;
|
$update = false;
|
||||||
$guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], parse_url($ret['url'], PHP_URL_HOST));
|
$guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url']);
|
||||||
|
|
||||||
// make sure to not overwrite existing values with blank entries except some technical fields
|
// make sure to not overwrite existing values with blank entries except some technical fields
|
||||||
$keep = ['batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'baseurl'];
|
$keep = ['batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'baseurl'];
|
||||||
|
|
|
@ -2034,9 +2034,10 @@ class Item
|
||||||
* Posts that are created on this system are using System::createUUID.
|
* Posts that are created on this system are using System::createUUID.
|
||||||
* Received ActivityPub posts are using Processor::getGUIDByURL.
|
* Received ActivityPub posts are using Processor::getGUIDByURL.
|
||||||
*
|
*
|
||||||
* @param string $uri uri of an item entry
|
* @param string $uri uri of an item entry
|
||||||
* @param string|null $host hostname for the GUID prefix
|
* @param string|null $host hostname for the GUID prefix
|
||||||
* @return string Unique guid
|
* @return string Unique guid
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function guidFromUri(string $uri, string $host = null): string
|
public static function guidFromUri(string $uri, string $host = null): string
|
||||||
{
|
{
|
||||||
|
@ -2047,11 +2048,16 @@ class Item
|
||||||
// Remove the scheme to make sure that "https" and "http" doesn't make a difference
|
// Remove the scheme to make sure that "https" and "http" doesn't make a difference
|
||||||
unset($parsed['scheme']);
|
unset($parsed['scheme']);
|
||||||
|
|
||||||
|
$hostPart = $host ?? $parsed['host'] ?? '';
|
||||||
|
if (!$hostPart) {
|
||||||
|
Logger::warning('Empty host GUID part', ['uri' => $uri, 'host' => $host, 'parsed' => $parsed, 'callstack' => System::callstack(10)]);
|
||||||
|
}
|
||||||
|
|
||||||
// Glue it together to be able to make a hash from it
|
// Glue it together to be able to make a hash from it
|
||||||
$host_id = implode('/', $parsed);
|
$host_id = implode('/', $parsed);
|
||||||
|
|
||||||
// Use a mixture of several hashes to provide some GUID like experience
|
// Use a mixture of several hashes to provide some GUID like experience
|
||||||
return hash('crc32', $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
|
return hash('crc32', $hostPart) . '-' . hash('joaat', $host_id) . '-' . hash('fnv164', $host_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,8 +59,7 @@ class Mail
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($msg['guid'])) {
|
if (empty($msg['guid'])) {
|
||||||
$host = parse_url($msg['from-url'], PHP_URL_HOST);
|
$msg['guid'] = Item::guidFromUri($msg['uri'], parse_url($msg['from-url'], PHP_URL_HOST));
|
||||||
$msg['guid'] = Item::guidFromUri($msg['uri'], $host);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg['created'] = (!empty($msg['created']) ? DateTimeFormat::utc($msg['created']) : DateTimeFormat::utcNow());
|
$msg['created'] = (!empty($msg['created']) ? DateTimeFormat::utc($msg['created']) : DateTimeFormat::utcNow());
|
||||||
|
|
|
@ -94,7 +94,7 @@ class NoScrape extends BaseModule
|
||||||
|
|
||||||
// We display the last activity (post or login), reduced to year and week number
|
// We display the last activity (post or login), reduced to year and week number
|
||||||
$last_active = strtotime($owner['last-item']);
|
$last_active = strtotime($owner['last-item']);
|
||||||
if ($last_active < strtotime($owner['last-activity'])) {
|
if ($owner['last-activity'] && $last_active < strtotime($owner['last-activity'])) {
|
||||||
$last_active = strtotime($owner['last-activity']);
|
$last_active = strtotime($owner['last-activity']);
|
||||||
}
|
}
|
||||||
$json_info['last-activity'] = date('o-W', $last_active);
|
$json_info['last-activity'] = date('o-W', $last_active);
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Tos extends BaseModule
|
||||||
*/
|
*/
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (strlen($this->config->get('system', 'singleuser'))) {
|
if ($this->config->get('system', 'singleuser')) {
|
||||||
$this->baseUrl->redirect('profile/' . $this->config->get('system', 'singleuser'));
|
$this->baseUrl->redirect('profile/' . $this->config->get('system', 'singleuser'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -687,7 +687,7 @@ class Probe
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = parse_url($uri);
|
$parts = parse_url($uri);
|
||||||
if (empty($parts['scheme']) && empty($parts['host']) && !strstr($parts['path'], '@')) {
|
if (empty($parts['scheme']) && empty($parts['host']) && (empty($parts['path']) || strpos($parts['path'], '@') === false)) {
|
||||||
Logger::info('URI was not detectable', ['uri' => $uri]);
|
Logger::info('URI was not detectable', ['uri' => $uri]);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -804,7 +804,7 @@ class Processor
|
||||||
private static function processContent(array $activity, array $item)
|
private static function processContent(array $activity, array $item)
|
||||||
{
|
{
|
||||||
if (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/markdown')) {
|
if (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/markdown')) {
|
||||||
$item['title'] = strip_tags($activity['name']);
|
$item['title'] = strip_tags($activity['name'] ?? '');
|
||||||
$content = Markdown::toBBCode($activity['content']);
|
$content = Markdown::toBBCode($activity['content']);
|
||||||
} elseif (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/bbcode')) {
|
} elseif (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/bbcode')) {
|
||||||
$item['title'] = $activity['name'];
|
$item['title'] = $activity['name'];
|
||||||
|
@ -1273,8 +1273,11 @@ class Processor
|
||||||
foreach ($receivers[$element] as $receiver) {
|
foreach ($receivers[$element] as $receiver) {
|
||||||
if ($receiver == ActivityPub::PUBLIC_COLLECTION) {
|
if ($receiver == ActivityPub::PUBLIC_COLLECTION) {
|
||||||
$name = Receiver::PUBLIC_COLLECTION;
|
$name = Receiver::PUBLIC_COLLECTION;
|
||||||
|
} elseif ($path = parse_url($receiver, PHP_URL_PATH)) {
|
||||||
|
$name = trim($path, '/');
|
||||||
} else {
|
} else {
|
||||||
$name = trim(parse_url($receiver, PHP_URL_PATH), '/');
|
Logger::warning('Unable to coerce name from receiver', ['receiver' => $receiver]);
|
||||||
|
$name = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$target = Tag::getTargetType($receiver);
|
$target = Tag::getTargetType($receiver);
|
||||||
|
|
|
@ -209,7 +209,7 @@ class Receiver
|
||||||
Logger::notice('No object data found', ['type' => $type, 'object_type' => $object_type, 'object_id' => $object_id, 'actor' => $actor, 'activity' => $activity]);
|
Logger::notice('No object data found', ['type' => $type, 'object_type' => $object_type, 'object_id' => $object_id, 'actor' => $actor, 'activity' => $activity]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::routeActivities($object_data, $type, true)) {
|
if (self::routeActivities($object_data, $type, true)) {
|
||||||
Logger::debug('Handled activity', ['type' => $type, 'object_type' => $object_type, 'object_id' => $object_id, 'actor' => $actor]);
|
Logger::debug('Handled activity', ['type' => $type, 'object_type' => $object_type, 'object_id' => $object_id, 'actor' => $actor]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1472,7 +1472,7 @@ class Receiver
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = ['type' => str_replace('as:', '', JsonLD::fetchElement($tag, '@type')),
|
$element = ['type' => str_replace('as:', '', JsonLD::fetchElement($tag, '@type') ?? ''),
|
||||||
'href' => JsonLD::fetchElement($tag, 'as:href', '@id'),
|
'href' => JsonLD::fetchElement($tag, 'as:href', '@id'),
|
||||||
'name' => JsonLD::fetchElement($tag, 'as:name', '@value')];
|
'name' => JsonLD::fetchElement($tag, 'as:name', '@value')];
|
||||||
|
|
||||||
|
|
|
@ -625,8 +625,8 @@ class Feed
|
||||||
|
|
||||||
$notify = Item::isRemoteSelf($contact, $item);
|
$notify = Item::isRemoteSelf($contact, $item);
|
||||||
|
|
||||||
// Distributed items should have a well formatted URI.
|
// Distributed items should have a well-formatted URI.
|
||||||
// Additionally we have to avoid conflicts with identical URI between imported feeds and these items.
|
// Additionally, we have to avoid conflicts with identical URI between imported feeds and these items.
|
||||||
if ($notify) {
|
if ($notify) {
|
||||||
$item['guid'] = Item::guidFromUri($orig_plink, DI::baseUrl()->getHostname());
|
$item['guid'] = Item::guidFromUri($orig_plink, DI::baseUrl()->getHostname());
|
||||||
$item['uri'] = Item::newURI($item['guid']);
|
$item['uri'] = Item::newURI($item['guid']);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user