diff --git a/src/Core/System.php b/src/Core/System.php index f94004a880..3feaac31dc 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -253,12 +253,12 @@ class System $func['database'] = in_array($func['class'], ['Friendica\Database\DBA', 'Friendica\Database\Database']); if (!$previous['database'] || !$func['database']) { $classparts = explode("\\", $func['class']); - $callstack[] = array_pop($classparts).'::'.$func['function']; + $callstack[] = array_pop($classparts).'::'.$func['function'] . '(' . $func['line'] . ')'; $previous = $func; } } elseif (!in_array($func['function'], $ignore)) { $func['database'] = ($func['function'] == 'q'); - $callstack[] = $func['function']; + $callstack[] = $func['function'] . '(' . $func['line'] . ')'; $func['class'] = ''; $previous = $func; } diff --git a/src/Model/ItemURI.php b/src/Model/ItemURI.php index 3194097f31..1755552299 100644 --- a/src/Model/ItemURI.php +++ b/src/Model/ItemURI.php @@ -81,4 +81,14 @@ class ItemURI return $itemuri['id'] ?? 0; } + + /** + * @param int $uriId + * @return bool + * @throws \Exception + */ + public static function exists(int $uriId): bool + { + return DBA::exists('item-uri', ['id' => $uriId]); + } } diff --git a/src/Model/Post/Media.php b/src/Model/Post/Media.php index 074cee5221..ef03b5fea5 100644 --- a/src/Model/Post/Media.php +++ b/src/Model/Post/Media.php @@ -30,6 +30,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\ItemURI; use Friendica\Model\Photo; use Friendica\Model\Post; use Friendica\Network\HTTPClient\Client\HttpClientAccept; @@ -89,6 +90,11 @@ class Media return; } + if (!ItemURI::exists($media['uri-id'])) { + Logger::info('Media referenced URI ID not found', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'callstack' => System::callstack()]); + return; + } + $media = self::unsetEmptyFields($media); $media = DI::dbaDefinition()->truncateFieldsForTable('post-media', $media); diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 368be55ddd..8509c30938 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -119,7 +119,7 @@ class Tag $tag = DBA::selectFirst('tag', ['name', 'type'], ['url' => $url]); if (!empty($tag)) { if ($tag['name'] != substr($name, 0, 96)) { - DBA::update('tag', ['name' => substr($name, 0, 96)], ['url' => $url]); + DBA::update('tag', ['name' => substr($name, 0, 96)], ['url' => $url, 'type' => $tag['type']]); } if (!empty($target) && ($tag['type'] != $target)) { DBA::update('tag', ['type' => $target], ['url' => $url]); diff --git a/src/Object/Image.php b/src/Object/Image.php index 00f8f3c5bb..d6c897e88d 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -196,7 +196,7 @@ class Image public function isValid(): bool { if ($this->isImagick()) { - return ($this->image !== false); + return !empty($this->image); } return $this->valid; }