Skip to content

Add the wiki's own search: a port of the Knowledge Base engine - #55

Merged
bonelifer merged 1 commit into
mainfrom
feature/wiki-search
Oct 13, 2026
Merged

bonelifer merged 1 commit into
mainfrom
feature/wiki-search

Conversation

@bonelifer

Copy link
Copy Markdown
Contributor

The wiki gets its own search, ported from the Knowledge Base. This is step 1 of docs/TODO/todo-forum-search-integration.md; step 2, a "Wiki (N)" block in phpBB's own search, is separate.

  • Engine. The KB's three backends (native, MySQL fulltext, PostgreSQL fulltext), the interface and the factory, renamed for the wiki. They index a new table, wiki_search_text, that holds one plain-text row for the live version of each article (BBCode, links, templates, tables and categories reduced to the words in them). Only the live version is searched: older versions and edits waiting for approval are not.
  • The page. /wiki/search, and a search box on the overview. Match all or any words, search titles only or text only, sort by last edit or title. Results show the title, description, a snippet with the words marked, and the date. It needs the wiki-read permission and phpBB's "Can use search", and follows the board's search switches.
  • Kept current. The index follows an article as it is saved, approved, set offline, put back and deleted, through one small service called from the existing code paths.
  • ACP. Extensions > Wiki > Search: switch the search on or off, results per page, the backend (only those the database can run are offered), and build or delete each backend's index. Building also rebuilds the plain-text copy.
  • Migration. New tables for the plain-text copy, the native backend's word list and matches, and cached results, with the settings and the ACP module. The word-match table's unique key includes descr_match; without it, an article whose description repeats a word from its text had its whole index insert fail silently.
  • New strings are in the English language files only. README and the TODO plan are updated.

Tests

  • Unit tests: 254 tests, 561 assertions, all pass, including the plain-text conversion. The code sniffer passes on the whole extension.
  • A new 21-check browser test covers the ACP page, backend switching, building and deleting the index, highlighted results, no match, titles only, and the index following a new article, an edit, a pending edit, approval, taking an article offline, putting it back and deleting it, plus the overview box and switching the search off. It passes on phpBB 3.3.19 with native on SQLite, MySQL and PostgreSQL, MySQL fulltext on MySQL and PostgreSQL fulltext on PostgreSQL; and on phpBB 4.0.0-a3-dev with native on SQLite, MySQL and PostgreSQL, MySQL fulltext on MySQL and PostgreSQL fulltext on PostgreSQL.
  • The other wiki browser tests (templates, tables, categories, parser functions, Start from, limits, markup) and the fixtures check still pass with search installed.

Investigated and written by Claude on behalf of William Jacoby (bonelifer).

The live version of each article is kept as plain text in wiki_search_text and indexed by
the backend chosen in the ACP: native, MySQL fulltext or PostgreSQL fulltext. /wiki/search
shows the matches with highlighted snippets, the overview has a search box, and the index
follows an article as it is saved, approved, set offline and deleted. The ACP page chooses
the backend, switches the search on and off, and builds or deletes the index.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bonelifer
bonelifer merged commit 4d952e4 into main Oct 13, 2026
58 checks passed
@bonelifer
bonelifer deleted the feature/wiki-search branch October 13, 2026 05:37
bonelifer added a commit that referenced this pull request Oct 13, 2026
Step 2 of the wiki search: matching wiki articles now appear next to the
results of phpBB's own search. The wiki's own search page came in with
#55.

- **The block.** A keyword search in phpBB's search, or from the header
search box, shows a **Wiki (N)** block above the forum results. It lists
the best matches with title, description, a marked snippet and date, and
ends with a "View all N wiki articles" link to the wiki's search page.
The forum results are not changed. It shows on the first page of results
only, only for members who may read the wiki, and not for searches by
author, within one topic, or the pre-made ones such as active topics.
- **The option.** The advanced search has an "Also search the Wiki" box,
ticked by default. An unticked box stays unticked through the pages of
results. It uses the core search events and two template events, so no
core file changes and no event request was needed.
- **ACP.** Extensions > Wiki > Search has two new settings: show wiki
matches in the board search (on or off), and the number of articles in
the block (1 to 50, default 5). The results per page of the wiki's own
search page is unchanged. All three backends are now listed on that
page; the ones the database cannot run are shown greyed out and cannot
be chosen.
- **Migration.** One new migration adds the two settings.
- **Shared service.** The wiki's search page and the block use one
search-results service, so the page's own code got shorter.
- **Fix in the ported backend.** On MySQL, the native backend reported a
total of 1 for titles-only and text-only searches whatever matched,
because the Knowledge Base's copy of the count query always counted one
row. It now counts the way phpBB core does. The block also shows only
when there are rows to show.
- **Docs.** README updated. The finished search plan moves to
`docs/TODO/archive/archive1.md` with a record of what was built and
covered. The TODO files record the decisions made for move/rename, the
starter-templates repository (name, packaging) and edit conflicts, and
drop the questions the built features already settled.

**Tests**

- Unit tests: 256 tests, 563 assertions, all pass. The code sniffer
passes on the whole extension.
- A new 27-check browser test covers the option on the advanced search,
the block above the forum results with highlighting and a matching
count, the header search box, an unticked box and its pages, no block
for author, topic and pre-made searches or when the wiki has no match,
titles-only and text-only counts, the block size setting, a member
without wiki read permission, and both ACP switches. The wiki's own
search test (22 or 23 checks) was re-run too. Both pass on phpBB 3.3.19
and phpBB 4.0.0-a3-dev, each on SQLite, MySQL and PostgreSQL with the
native backend, and with MySQL fulltext on MySQL and PostgreSQL fulltext
on PostgreSQL.
- Not covered locally: the Windows and MSSQL jobs that run in CI, and
styles other than prosilver.
- The same MySQL count bug exists in the Knowledge Base's copy of the
backend. That is for a separate change in that repository.

---

Investigated and written by [Claude](https://www.anthropic.com/claude)
on behalf of William Jacoby ([bonelifer](https://github.com/bonelifer)).

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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