mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 10:31:59 -04:00
Fix exception for duplicate ebook placeholder on save
This commit is contained in:
parent
d9fe3e9303
commit
94d62fdcdf
2 changed files with 47 additions and 36 deletions
|
@ -1916,7 +1916,8 @@ final class Ebook{
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws Exceptions\InvalidEbookException
|
||||
* @throws Exceptions\InvalidEbookException If the `Ebook` is invalid.
|
||||
* @throws Exceptions\DuplicateEbookException If an `Ebook` with the same title and author already exists.
|
||||
*/
|
||||
public function Save(): void{
|
||||
$this->Validate();
|
||||
|
@ -1932,6 +1933,7 @@ final class Ebook{
|
|||
throw $error;
|
||||
}
|
||||
|
||||
try{
|
||||
Db::Query('
|
||||
UPDATE Ebooks
|
||||
set
|
||||
|
@ -1966,6 +1968,10 @@ final class Ebook{
|
|||
$this->Language, $this->WordCount, $this->ReadingEase, $this->GitHubUrl, $this->WikipediaUrl,
|
||||
$this->EbookCreated, $this->EbookUpdated, $this->TextSinglePageByteCount, $this->IndexableText,
|
||||
$this->EbookId]);
|
||||
}
|
||||
catch(Exceptions\DuplicateDatabaseKeyException){
|
||||
throw new Exceptions\DuplicateEbookException($this->Identifier);
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
|
|
|
@ -69,7 +69,12 @@ try{
|
|||
$ebook->EbookId = $originalEbook->EbookId;
|
||||
$ebook->Created = $originalEbook->Created;
|
||||
|
||||
try{
|
||||
$ebook->Save();
|
||||
}
|
||||
catch(Exceptions\DuplicateEbookException){
|
||||
throw new Exceptions\EbookPlaceholderExistsException();
|
||||
}
|
||||
|
||||
$_SESSION['is-ebook-placeholder-saved'] = true;
|
||||
http_response_code(Enums\HttpCode::SeeOther->value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue