Check for URI ID existence in Post\Media::insert
- Address https://github.com/friendica/friendica/issues/12486#issuecomment-1374538325
This commit is contained in:
parent
4d5d8e5b64
commit
b77f3a7525
2 changed files with 16 additions and 0 deletions
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue