Skip to content

Commit

Permalink
fix: handle elasticsearch index errors correct, improve notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Sep 1, 2023
1 parent 9b71a96 commit 5b4fc12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 4 additions & 3 deletions phpmyfaq/src/phpMyFAQ/Instance/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use phpMyFAQ\Configuration;
use phpMyFAQ\Configuration\ElasticsearchConfiguration;
use phpMyFAQ\Core\Exception;
use stdClass;

/**
* Class Elasticsearch
Expand Down Expand Up @@ -200,7 +201,7 @@ public function dropIndex(): object
*
* @param string[] $faq
*/
public function index(array $faq): object
public function index(array $faq): ?object
{
$params = [
'index' => $this->esConfig->getIndex(),
Expand All @@ -217,8 +218,8 @@ public function index(array $faq): object

try {
return $this->client->index($params)->asObject();
} catch (ClientResponseException | MissingParameterException | ServerResponseException) {
//return ['error' => $e->getMessage()];
} catch (ClientResponseException | MissingParameterException | ServerResponseException $e) {
$this->config->getLogger()->error('Index error.', [$e->getMessage()]);
}
}

Expand Down
15 changes: 8 additions & 7 deletions phpmyfaq/src/phpMyFAQ/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ public function sendNewFaqAdded(array $emails, int $faqId, string $faqLanguage):
$link = new Link($url, $this->config);
$link->itemTitle = $this->faq->getRecordTitle($faqId);

$this->mail->message = html_entity_decode(
Translation::get('msgMailCheck')
) . "<p><strong>" . Translation::get('msgAskYourQuestion') . "</strong> "
. $this->faq->getRecordTitle($faqId) . "</p>"
. $this->faq->faqRecord['content']
. "<br />" . $this->config->getTitle()
. ': <a target="_blank" href="' . $link->toString() . '">' . $link->toString() . '</a>';
$this->mail->message = html_entity_decode(Translation::get('msgMailCheck')) .
"<p><strong>" . Translation::get('msgAskYourQuestion') . ":</strong> " .
$this->faq->getRecordTitle($faqId) . "</p>" .
"<p><strong>" . Translation::get('msgNewContentArticle') . ":</strong> " .
$this->faq->faqRecord['content'] . "</p>" .
"<hr>" .
$this->config->getTitle() .
': <a target="_blank" href="' . $link->toString() . '">' . $link->toString() . '</a>';

$this->mail->contentType = 'text/html';

Expand Down

0 comments on commit 5b4fc12

Please sign in to comment.