Merge pull request #12952 from MrPetovan/bug/fatal-errors

Address a few fatal errors
This commit is contained in:
Philipp 2023-03-31 14:35:37 +02:00 committed by GitHub
commit c77266de98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 25 deletions

View file

@ -40,6 +40,7 @@ use Friendica\Network\HTTPException\ForbiddenException;
use Friendica\Network\Probe;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use GuzzleHttp\Psr7\Uri;
use Psr\Log\LoggerInterface;
class Follow extends BaseModule
@ -223,17 +224,26 @@ class Follow extends BaseModule
protected function followRemoteItem(string $url)
{
$itemId = Item::fetchByLink($url, $this->session->getLocalUserId());
if (!$itemId) {
// If the user-specific search failed, we search and probe a public post
$itemId = Item::fetchByLink($url);
}
if (!empty($itemId)) {
$item = Post::selectFirst(['guid'], ['id' => $itemId]);
if (!empty($item['guid'])) {
$this->baseUrl->redirect('display/' . $item['guid']);
try {
$uri = new Uri($url);
if (!$uri->getScheme()) {
return;
}
$itemId = Item::fetchByLink($url, $this->session->getLocalUserId());
if (!$itemId) {
// If the user-specific search failed, we search and probe a public post
$itemId = Item::fetchByLink($url);
}
if (!empty($itemId)) {
$item = Post::selectFirst(['guid'], ['id' => $itemId]);
if (!empty($item['guid'])) {
$this->baseUrl->redirect('display/' . $item['guid']);
}
}
} catch (\InvalidArgumentException $e) {
return;
}
}
}

View file

@ -121,11 +121,14 @@ class Contacts extends Module\BaseProfile
['uri-id' => $contact['uri-id'], 'uid' => [0, $this->userSession->getLocalUserId()]],
['order' => ['uid' => 'DESC']]
);
return Module\Contact::getContactTemplateVars($contact);
return $contact ? Module\Contact::getContactTemplateVars($contact) : null;
},
Model\Contact::selectToArray(['uri-id'], $condition, $params)
);
// Remove nonexistent contacts
$contacts = array_filter($contacts);
$desc = '';
switch ($type) {
case 'followers':