Skip to content

feat(kb): endpoints for FAQ articles and categories (2.8.0) - #17

Merged
studio-prisma merged 1 commit into
mainfrom
feat/kb-endpoints
Nov 8, 2026
Merged

studio-prisma merged 1 commit into
mainfrom
feat/kb-endpoints

Conversation

@studio-prisma

Copy link
Copy Markdown
Owner

What

Knowledge base endpoints for FAQ categories and articles (2.8.0):

  • GET kb-categories-list.php, POST kb-categories-create.php, PATCH kb-categories-update.php/{id}.json
  • GET kb-faq-search.php (text, category, visibility, slug, paging), GET kb-faq-get.php/{id}.json
  • POST kb-faq-create.php, PATCH kb-faq-update.php/{id}.json (title, answer, category, notes, visibility)

No delete. Hiding an article means visibility: internal. New content is internal unless set otherwise.

How

  • lib/Services/KbService.php; writes go through FAQ::update() / Category::update(), so HTML is sanitized like in the staff UI and duplicates are refused.
  • Partial updates fill in the stored values: FAQ::update() would otherwise clear notes and help topics.
  • Category parent changes refuse self-parenting and moving below a descendant (osTicket's category name builder would loop).
  • Friendly URLs: the slug is parsed read-only from RewriteRule ^kb/<slug>$ kb/faq.php?id=<ID> in the root .htaccess (fixed path, size cap). Responses carry slug, publicUrl, visibleInPortal.
  • Permissions can_read_kb, can_write_kb (default off), rendered and saved with the task permissions.

Fix included

Since 2.6.0 every update left the task rewrite rules behind in api/.htaccess (block removal stopped at the subticket unlink rule). The template now ends with an explicit end marker, and leftover plugin rules are stripped. Verified in the devlab: duplicate task rules gone, osTicket's own rules untouched.

Tests

  • PHPUnit (PHP 8.3 container): 311 tests green, new: KbEndpointAccessTest, KbServiceTest, HtaccessLeftoverTest.
  • devlab osTicket 1.18.4: migration adds both columns, 7 files + rewrite rules deployed; all endpoints called for real: 401 without permission, read-only key cannot write, XSS probe (<script>, onerror, javascript:) neutralized by osTicket, partial update keeps notes and help topics, duplicate title 400, invalid visibility/slug/id 400, unknown article 404, DELETE 405, cycle refused. Admin permission table renders the two checkboxes and saves them.

List, create and change FAQ categories; search, read, create and change
FAQ articles including internal/public/featured. No delete. Changes go
through FAQ::update() and Category::update(); partial updates keep notes,
help topics and attachments. Slugs for /kb/<slug> are read from the root
.htaccess, never written. New permissions can_read_kb and can_write_kb.

Also fixes the api/.htaccess cleanup on update, which left the task rules
behind since 2.6.0.
@studio-prisma
studio-prisma merged commit 1247322 into main Nov 8, 2026
8 checks passed
@studio-prisma
studio-prisma deleted the feat/kb-endpoints branch November 8, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant