Make IndexableText optional

Placeholders do not have FullTitle, AlternateTitle, Tags, LocSubjects,
or TocEntries.
This commit is contained in:
Mike Colagrosso 2025-02-11 14:42:32 -07:00 committed by Alex Cabal
parent 1629d3a1a1
commit a3ce3f1ec1
3 changed files with 7 additions and 20 deletions

View file

@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS `Ebooks` (
`EbookCreated` datetime NULL,
`EbookUpdated` datetime NULL,
`TextSinglePageByteCount` bigint unsigned NULL,
`IndexableText` text NOT NULL,
`IndexableText` text NULL,
`IndexableAuthors` text NOT NULL,
`IndexableCollections` text NULL,
PRIMARY KEY (`EbookId`),

View file

@ -43,7 +43,7 @@ use function Safe\shell_exec;
* @property string $TextUrl
* @property string $TextSinglePageUrl
* @property string $TextSinglePageSizeFormatted
* @property string $IndexableText
* @property ?string $IndexableText
* @property string $IndexableAuthors
* @property ?string $IndexableCollections
* @property ?EbookPlaceholder $EbookPlaceholder
@ -129,7 +129,7 @@ final class Ebook{
protected string $_TextUrl;
protected string $_TextSinglePageUrl;
protected string $_TextSinglePageSizeFormatted;
protected string $_IndexableText;
protected ?string $_IndexableText = null;
protected string $_IndexableAuthors;
protected ?string $_IndexableCollections = null;
protected ?EbookPlaceholder $_EbookPlaceholder = null;
@ -708,7 +708,7 @@ final class Ebook{
return $this->_TextSinglePageSizeFormatted;
}
protected function GetIndexableText(): string{
protected function GetIndexableText(): ?string{
if(!isset($this->_IndexableText)){
$this->_IndexableText = $this->FullTitle ?? '';
@ -1573,15 +1573,9 @@ final class Ebook{
}
}
if(isset($this->IndexableText)){
$this->IndexableText = trim($this->IndexableText);
if($this->IndexableText == ''){
$error->Add(new Exceptions\EbookIndexableTextRequiredException());
}
}
else{
$error->Add(new Exceptions\EbookIndexableTextRequiredException());
$this->IndexableText = trim($this->IndexableText ?? '');
if($this->IndexableText == ''){
$this->IndexableText = null;
}
if(isset($this->IndexableAuthors)){

View file

@ -1,7 +0,0 @@
<?
namespace Exceptions;
class EbookIndexableTextRequiredException extends AppException{
/** @var string $message */
protected $message = 'Ebook IndexableText required.';
}