$content_fields['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $content_fields['raw-body']);
$content_fields['raw-body'] = self::setHashtags($content_fields['raw-body']);
- if ($item['author-network'] != Protocol::DFRN) {
- Post\Media::insertFromRelevantUrl($item['uri-id'], $content_fields['raw-body']);
- }
-
+ Post\Media::insertFromRelevantUrl($item['uri-id'], $content_fields['raw-body']);
Post\Content::update($item['uri-id'], $content_fields);
}
$item['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $item['raw-body']);
$item['raw-body'] = self::setHashtags($item['raw-body']);
- if (!DBA::exists('contact', ['id' => $item['author-id'], 'network' => Protocol::DFRN])) {
- Post\Media::insertFromRelevantUrl($item['uri-id'], $item['raw-body']);
- }
+ Post\Media::insertFromRelevantUrl($item['uri-id'], $item['raw-body']);
// Check for hashtags in the body and repair or add hashtag links
$item['body'] = self::setHashtags($item['body']);
{
// Make sure that for example site parameters aren't used when testing if the link is contained in the body
$urlparts = parse_url($url);
- if (!empty($urlparts)) {
- unset($urlparts['query']);
- unset($urlparts['fragment']);
+ if (empty($urlparts)) {
+ return false;
+ }
+
+ unset($urlparts['query']);
+ unset($urlparts['fragment']);
+
+ try {
$url = (string)Uri::fromParts($urlparts);
- } else {
+ } catch (\InvalidArgumentException $e) {
+ DI::logger()->notice('Invalid URL', ['$url' => $url, '$urlparts' => $urlparts]);
+ /* See https://github.com/friendica/friendica/issues/12113
+ * Malformed URLs will result in a Fatal Error
+ */
return false;
}
if (strpos($body, $url)) {
return true;
}
+
foreach ([0, 1, 2] as $size) {
if (preg_match('#/photo/.*-' . $size . '\.#ism', $url) &&
strpos(preg_replace('#(/photo/.*)-[012]\.#ism', '$1-' . $size . '.', $body), $url)) {
return true;
}
}
+
return false;
}
$percent = $option['replies'] / $question['voters'] * 100;
$options[$key]['vote'] = DI::l10n()->tt('%2$s (%3$d%%, %1$d vote)', '%2$s (%3$d%%, %1$d votes)', $option['replies'], $option['name'], round($percent, 1));
} else {
- $options[$key]['vote'] = DI::l10n()->tt('%2$s (%1$d vote)', '%2$s (%1$d votes)', $option['replies'], $option['name'], );
+ $options[$key]['vote'] = DI::l10n()->tt('%2$s (%1$d vote)', '%2$s (%1$d votes)', $option['replies'], $option['name']);
}
}
$shared_item = Post::selectFirst(['uri-id'], ['guid' => $shared['guid'], 'uid' => [0, $uid]]);
if (!empty($shared_item['uri-id'])) {
Logger::debug('Found post by guid', ['guid' => $shared['guid'], 'uid' => $uid]);
+ return $shared_item['uri-id'];
}
}
- if (empty($shared_item['uri-id']) && !empty($shared['message_id'])) {
+ if (!empty($shared['message_id'])) {
$shared_item = Post::selectFirst(['uri-id'], ['uri' => $shared['message_id'], 'uid' => [0, $uid]]);
if (!empty($shared_item['uri-id'])) {
Logger::debug('Found post by message_id', ['message_id' => $shared['message_id'], 'uid' => $uid]);
+ return $shared_item['uri-id'];
}
}
- if (empty($shared_item['uri-id']) && !empty($shared['link'])) {
+ if (!empty($shared['link'])) {
$shared_item = Post::selectFirst(['uri-id'], ['plink' => $shared['link'], 'uid' => [0, $uid]]);
if (!empty($shared_item['uri-id'])) {
Logger::debug('Found post by link', ['link' => $shared['link'], 'uid' => $uid]);
+ return $shared_item['uri-id'];
}
}
- if (empty($shared_item['uri-id'])) {
- $url = $shared['message_id'] ?: $shared['link'];
- $id = self::fetchByLink($url);
- if (!$id) {
- Logger::notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
- return 0;
- }
+ $url = $shared['message_id'] ?: $shared['link'];
+ $id = self::fetchByLink($url);
+ if (!$id) {
+ Logger::notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
+ return 0;
+ }
+ $shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
+ if (!empty($shared_item['uri-id'])) {
Logger::debug('Fetched shared post', ['id' => $id, 'url' => $url, 'uid' => $uid]);
-
- $shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
- if (!DBA::isResult($shared_item)) {
- Logger::warning('Post does not exist.', ['id' => $id, 'url' => $url, 'uid' => $uid]);
- return 0;
- }
+ return $shared_item['uri-id'];
}
- return $shared_item['uri-id'];
+ Logger::warning('Post does not exist although it was supposed to had been fetched.', ['id' => $id, 'url' => $url, 'uid' => $uid]);
+ return 0;
}
}