Avoid some database errors

This commit is contained in:
Michael 2022-08-25 04:57:41 +00:00
parent 4e3102bfb3
commit 15d975f143
3 changed files with 5 additions and 2 deletions

View File

@ -85,6 +85,7 @@ class Media
}
$media = self::unsetEmptyFields($media);
$media = DI::dbaDefinition()->truncateFieldsForTable('post-media', $media);
// We are storing as fast as possible to avoid duplicated network requests
// when fetching additional information for pictures and other content.
@ -94,6 +95,7 @@ class Media
$media = self::fetchAdditionalData($media);
$media = self::unsetEmptyFields($media);
$media = DI::dbaDefinition()->truncateFieldsForTable('post-media', $media);
if (array_diff_assoc($media, $stored)) {
$result = DBA::insert('post-media', $media, Database::INSERT_UPDATE);

View File

@ -251,7 +251,7 @@ class Notification extends BaseRepository
$this->db->update(self::$table_name, $fields, ['id' => $Notification->id]);
} else {
$fields['created'] = DateTimeFormat::utcNow();
$this->db->insert(self::$table_name, $fields);
$this->db->insert(self::$table_name, $fields, Database::INSERT_IGNORE);
$Notification = $this->selectOneById($this->db->lastInsertId());
}

View File

@ -29,6 +29,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\APContact;
@ -1911,7 +1912,7 @@ class Receiver
private static function addArrivedId(string $id)
{
DBA::delete('arrived-activity', ["`received` < ?", DateTimeFormat::utc('now - 5 minutes')]);
DBA::insert('arrived-activity', ['object-id' => $id, 'received' => DateTimeFormat::utcNow()]);
DBA::insert('arrived-activity', ['object-id' => $id, 'received' => DateTimeFormat::utcNow()], Database::INSERT_IGNORE);
}
/**