Avoid "Duplicate entry" error in apcontact
This commit is contained in:
parent
cd53996a6e
commit
a0cb6b409d
1 changed files with 8 additions and 3 deletions
|
@ -320,13 +320,18 @@ class APContact
|
|||
|
||||
$apcontact['updated'] = DateTimeFormat::utcNow();
|
||||
|
||||
DBA::update('apcontact', $apcontact, ['url' => $url], true);
|
||||
|
||||
// We delete the old entry when the URL is changed
|
||||
if (($url != $apcontact['url']) && DBA::exists('apcontact', ['url' => $url]) && DBA::exists('apcontact', ['url' => $apcontact['url']])) {
|
||||
if ($url != $apcontact['url']) {
|
||||
Logger::info('Delete changed profile url', ['old' => $url, 'new' => $apcontact['url']]);
|
||||
DBA::delete('apcontact', ['url' => $url]);
|
||||
}
|
||||
|
||||
if (DBA::exists('apcontact', ['url' => $apcontact['url']])) {
|
||||
DBA::update('apcontact', $apcontact, ['url' => $apcontact['url']]);
|
||||
} else {
|
||||
DBA::replace('apcontact', $apcontact);
|
||||
}
|
||||
|
||||
Logger::info('Updated profile', ['url' => $url]);
|
||||
|
||||
return $apcontact;
|
||||
|
|
Loading…
Reference in a new issue