summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorFaraz Samapoor <f.samapoor@gmail.com>2023-11-09 14:33:05 +0330
committerFaraz Samapoor <f.samapoor@gmail.com>2024-01-15 10:36:02 +0330
commitcdf9d94423f7a6ee2f825cec86278e5f977de493 (patch)
treeefe0b2dfb8ab9eb1b6ebef6345b83807c4f9fb4e /lib/private
parent28450718541b331f6db6da92cb22dd44879f7727 (diff)
downloadnextcloud-server-cdf9d94423f7a6ee2f825cec86278e5f977de493.tar.gz
nextcloud-server-cdf9d94423f7a6ee2f825cec86278e5f977de493.zip
Adds new exception to check for the availability of the index.
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com> Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/FullTextSearch/Model/IndexDocument.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php
index 76638e23894..1b2e0eb5896 100644
--- a/lib/private/FullTextSearch/Model/IndexDocument.php
+++ b/lib/private/FullTextSearch/Model/IndexDocument.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OC\FullTextSearch\Model;
use JsonSerializable;
+use OCP\FullTextSearch\Exceptions\FullTextSearchIndexNotAvailableException;
use OCP\FullTextSearch\Model\IDocumentAccess;
use OCP\FullTextSearch\Model\IIndex;
use OCP\FullTextSearch\Model\IIndexDocument;
@@ -51,7 +52,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
protected DocumentAccess $access;
- protected IIndex $index;
+ protected ?IIndex $index = null;
protected int $modifiedTime = 0;
@@ -136,9 +137,14 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
/**
* Get the Index.
*
+ * @throws FullTextSearchIndexNotAvailableException
* @since 15.0.0
*/
final public function getIndex(): IIndex {
+ if ($this->index === null) {
+ throw new FullTextSearchIndexNotAvailableException('No IIndex generated');
+ }
+
return $this->index;
}
@@ -148,7 +154,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* @since 16.0.0
*/
final public function hasIndex(): bool {
- return isset($this->index);
+ return $this->index !== null;
}
/**