Merge pull request #983 from nextcloud/bugfix/980/fts-argument-type

Bugfix/980/fts argument type
This commit is contained in:
Julius Härtl
2019-04-10 17:28:54 +02:00
committed by GitHub
2 changed files with 27 additions and 16 deletions

View File

@@ -191,7 +191,7 @@ class Application extends App {
}
public function registerFullTextSearch() {
if (Util::getVersion()[0] < 16) {
if (Util::getVersion()[0] < 16 || !\OC::$server->getAppManager()->isEnabledForUser('fulltextsearch')) {
return;
}

View File

@@ -40,6 +40,7 @@ use OCA\Deck\Db\StackMapper;
use OCA\Deck\Provider\DeckProvider;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\FullTextSearch\Exceptions\FullTextSearchAppNotAvailableException;
use OCP\FullTextSearch\IFullTextSearchManager;
use OCP\FullTextSearch\Model\IDocumentAccess;
use OCP\FullTextSearch\Model\IIndex;
@@ -95,9 +96,12 @@ class FullTextSearchService {
$cardId = $e->getArgument('id');
$userId = $e->getArgument('userId');
$this->fullTextSearchManager->createIndex(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, $userId, IIndex::INDEX_FULL
);
try {
$this->fullTextSearchManager->createIndex(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, $userId, IIndex::INDEX_FULL
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}
@@ -107,9 +111,12 @@ class FullTextSearchService {
public function onCardUpdated(GenericEvent $e) {
$cardId = $e->getArgument('id');
$this->fullTextSearchManager->updateIndexStatus(
try {
$this->fullTextSearchManager->updateIndexStatus(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, IIndex::INDEX_CONTENT
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}
@@ -119,9 +126,12 @@ class FullTextSearchService {
public function onCardDeleted(GenericEvent $e) {
$cardId = $e->getArgument('id');
$this->fullTextSearchManager->updateIndexStatus(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, IIndex::INDEX_REMOVE
);
try {
$this->fullTextSearchManager->updateIndexStatus(
DeckProvider::DECK_PROVIDER_ID, (string)$cardId, IIndex::INDEX_REMOVE
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}
@@ -129,7 +139,7 @@ class FullTextSearchService {
* @param GenericEvent $e
*/
public function onBoardShares(GenericEvent $e) {
$boardId = $e->getArgument('boardId');
$boardId = (int)$e->getArgument('boardId');
$cards = array_map(
function(Card $item) {
@@ -137,9 +147,12 @@ class FullTextSearchService {
},
$this->getCardsFromBoard($boardId)
);
$this->fullTextSearchManager->updateIndexesStatus(
DeckProvider::DECK_PROVIDER_ID, $cards, IIndex::INDEX_META
);
try {
$this->fullTextSearchManager->updateIndexesStatus(
DeckProvider::DECK_PROVIDER_ID, $cards, IIndex::INDEX_META
);
} catch (FullTextSearchAppNotAvailableException $e) {
}
}
@@ -167,7 +180,7 @@ class FullTextSearchService {
$document->setTitle($card->getTitle());
$document->setContent($card->getDescription());
$document->setAccess($this->generateDocumentAccessFromCardId($card->getId()));
$document->setAccess($this->generateDocumentAccessFromCardId((int)$card->getId()));
}
@@ -181,9 +194,7 @@ class FullTextSearchService {
public function generateDocumentAccessFromCardId(int $cardId): IDocumentAccess {
$board = $this->getBoardFromCardId($cardId);
$access = new DocumentAccess($board->getOwner());
return $access;
return new DocumentAccess($board->getOwner());
}