mirror of
https://github.com/standardebooks/web.git
synced 2025-07-08 07:40:39 -04:00
Fix validation of existing artwork name when creating a new artwork
This commit is contained in:
parent
4bec47a389
commit
59083baf8c
1 changed files with 7 additions and 10 deletions
|
@ -509,18 +509,15 @@ class Artwork{
|
|||
}
|
||||
|
||||
// Check for existing `Artwork` objects with the same URL but different `ArtworkID`s.
|
||||
if(isset($this->ArtworkId)){
|
||||
try{
|
||||
$existingArtwork = Artwork::GetByUrl($this->Artist->UrlName, $this->UrlName);
|
||||
if($existingArtwork->ArtworkId != $this->ArtworkId){
|
||||
// Duplicate found, alert the user.
|
||||
$error->Add(new Exceptions\ArtworkAlreadyExistsException());
|
||||
}
|
||||
}
|
||||
catch(Exceptions\ArtworkNotFoundException){
|
||||
// No duplicates found, continue.
|
||||
try{
|
||||
$existingArtwork = Artwork::GetByUrl($this->Artist->UrlName, $this->UrlName);
|
||||
if(!isset($this->ArtworkId) || $existingArtwork->ArtworkId != $this->ArtworkId){
|
||||
$error->Add(new Exceptions\ArtworkAlreadyExistsException());
|
||||
}
|
||||
}
|
||||
catch(Exceptions\ArtworkNotFoundException){
|
||||
// No duplicates found, continue.
|
||||
}
|
||||
|
||||
if($isImageRequired){
|
||||
if($imagePath === null){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue