We are getting the following error when trying to apply a draft on a craft 5.7.6 site with typesense 5.7.2.1:
percipiolondon\typesense\controllers\DocumentsController::handleSave(): Argument #1 ($entry) must be of type craft\elements\Entry, null given, called in /var/www/html/vendor/craftpulse/craft-typesense/src/controllers/DocumentsController.php on line 66
It looks like the entry query isn't finding the draft. I'm not sure if it should or shouldn't find an entry that is a draft, but perhaps an addition that doesn't call the handleSave function unless there is an entry returned? Changing this:
if ($event->name === Elements::EVENT_AFTER_RESTORE_ELEMENT || $event->name === Structures::EVENT_AFTER_MOVE_ELEMENT) {
foreach($element->getSupportedSites() as $site) {
if ($site['siteId'] ?? null) {
$entry = Entry::find()->id($element->id)->siteId($site['siteId'])->one();
$this->handleSave($entry);
}
}
}
to
if ($event->name === Elements::EVENT_AFTER_RESTORE_ELEMENT || $event->name === Structures::EVENT_AFTER_MOVE_ELEMENT) {
foreach($element->getSupportedSites() as $site) {
if ($site['siteId'] ?? null) {
$entry = Entry::find()->id($element->id)->siteId($site['siteId'])->one();
if ($entry) {
$this->handleSave($entry);
}
}
}
}
We are getting the following error when trying to apply a draft on a craft 5.7.6 site with typesense 5.7.2.1:
It looks like the entry query isn't finding the draft. I'm not sure if it should or shouldn't find an entry that is a draft, but perhaps an addition that doesn't call the handleSave function unless there is an entry returned? Changing this:
to