Merge pull request #11863 from annando/database

Avoid some database errors
This commit is contained in:
Tobias Diekershoff 2022-08-25 13:49:05 +02:00 committed by GitHub
commit fde853897f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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);
}
/**