Skip to content

Commit 77c3da2

Browse files
committed
feat(api): added configuration for orphaned FAQs in API (#3876)
1 parent cc4c244 commit 77c3da2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

phpmyfaq/src/phpMyFAQ/Controller/Api/FaqController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,14 @@ public function list(): JsonResponse
539539
);
540540

541541
$onlyActive = (bool) $this->configuration->get('api.onlyActiveFaqs');
542+
$ignoreOrphanedFaqs = (bool) $this->configuration->get('api.ignoreOrphanedFaqs');
542543

543544
// Get all FAQs (this populates $faq->faqRecords)
544545
$faq->getAllFaqs(
545546
FAQ_SORTING_TYPE_CATID_FAQID,
546547
[
547548
'lang' => $this->configuration->getLanguage()->getLanguage(),
548-
'fcr.category_id' => 'IS NOT NULL',
549+
'fcr.category_id' => $ignoreOrphanedFaqs ? 'IS NOT NULL' : null,
549550
'fd.active' => $onlyActive ? 'yes' : null,
550551
],
551552
$sort->getOrderSql(),

phpmyfaq/src/phpMyFAQ/Faq.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,9 @@ public function getAllFaqs(
13331333
): void {
13341334
$where = '';
13351335
if (!is_null($condition)) {
1336+
// Filter out null values from conditions
1337+
$condition = array_filter($condition, fn($value) => $value !== null);
1338+
13361339
$num = count($condition);
13371340
$where = 'WHERE ';
13381341
foreach ($condition as $field => $data) {

0 commit comments

Comments
 (0)