Add "Database::INSERT_IGNORE" for the initial value check

This commit is contained in:
Philipp 2023-01-21 20:02:40 +01:00
parent eefd0b1143
commit a7c4a3023a
No known key found for this signature in database
GPG key ID: 24A7501396EB5432

View file

@ -783,7 +783,7 @@ class DBStructure
} }
if (!DBA::exists('verb', ['id' => 0])) { if (!DBA::exists('verb', ['id' => 0])) {
DBA::insert('verb', ['name' => '']); DBA::insert('verb', ['name' => ''], Database::INSERT_IGNORE);
$lastid = DBA::lastInsertId(); $lastid = DBA::lastInsertId();
if ($lastid != 0) { if ($lastid != 0) {
DBA::update('verb', ['id' => 0], ['id' => $lastid]); DBA::update('verb', ['id' => 0], ['id' => $lastid]);
@ -819,7 +819,7 @@ class DBStructure
} }
if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) { if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) {
DBA::insert('contact', ['nurl' => '']); DBA::insert('contact', ['nurl' => ''], Database::INSERT_IGNORE);
$lastid = DBA::lastInsertId(); $lastid = DBA::lastInsertId();
if ($lastid != 0) { if ($lastid != 0) {
DBA::update('contact', ['id' => 0], ['id' => $lastid]); DBA::update('contact', ['id' => 0], ['id' => $lastid]);
@ -834,7 +834,7 @@ class DBStructure
} }
if (self::existsTable('tag') && !DBA::exists('tag', ['id' => 0])) { if (self::existsTable('tag') && !DBA::exists('tag', ['id' => 0])) {
DBA::insert('tag', ['name' => '']); DBA::insert('tag', ['name' => ''], Database::INSERT_IGNORE);
$lastid = DBA::lastInsertId(); $lastid = DBA::lastInsertId();
if ($lastid != 0) { if ($lastid != 0) {
DBA::update('tag', ['id' => 0], ['id' => $lastid]); DBA::update('tag', ['id' => 0], ['id' => $lastid]);
@ -850,7 +850,7 @@ class DBStructure
if (self::existsTable('permissionset')) { if (self::existsTable('permissionset')) {
if (!DBA::exists('permissionset', ['id' => 0])) { if (!DBA::exists('permissionset', ['id' => 0])) {
DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']); DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''], Database::INSERT_IGNORE);
$lastid = DBA::lastInsertId(); $lastid = DBA::lastInsertId();
if ($lastid != 0) { if ($lastid != 0) {
DBA::update('permissionset', ['id' => 0], ['id' => $lastid]); DBA::update('permissionset', ['id' => 0], ['id' => $lastid]);
@ -878,7 +878,7 @@ class DBStructure
} }
$fields = ['id' => $set['psid'], 'uid' => $set['uid'], 'allow_cid' => $permission, $fields = ['id' => $set['psid'], 'uid' => $set['uid'], 'allow_cid' => $permission,
'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']; 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''];
DBA::insert('permissionset', $fields); DBA::insert('permissionset', $fields, Database::INSERT_IGNORE);
} }
DBA::close($sets); DBA::close($sets);
} }