Knowledge Batch PR Review - edmozley/freeitsm GitHub Wiki
Knowledge batch - PR review
Nine PRs by @Dr4inder ยท Issues #472, #473, #475, #476 ยท Merged 1 Dec 2026
A run of Knowledge fixes and two features from @Dr4inder - careful, well-tested work, each PR with a browser test that fails on the old code. Thank you. Four were merged as they were; five were merged and then given a follow-up commit (45dee9c0c). User pages: Knowledge ยท Knowledge - folders and security. Developer page: Folder soft delete, resizable panel and folder totals.
The nine
| PR | Kind | What it did | Verdict |
|---|---|---|---|
| #462 | Bug | An article's tick box could disagree with the selection (count and highlight changed, the box did not, or a phantom tick stayed) - the shared handler cancelled the checkbox's own click, so the browser put the old state back. Now only a click on the surrounding label is cancelled. | โ Merge |
| #461 | Bug | Choosing a folder in Tree reloaded the whole tree behind a spinner and jumped to the top; choosing one in the sidebar did not bring it into view. Now the loaded tree stays, its highlight and breadcrumb update, and a sidebar choice scrolls the folder into view when it is off screen. | ๐ง Merge + fix |
| #471 | Feature | A draggable, keyboard-usable divider to resize the folder panel (200px to half the window, remembered per browser). | ๐ง Merge + fix |
| #482 | Bug (#472) | A folder's count included only its own articles, so a folder of subfolders read 0. folderTotal() adds up everything beneath it, from the already-permission-filtered folder list. |
๐ง Merge + fix |
| #483 | Bug (#473) | Leaving Tree for List or Cards kept the Tree's flattened set of every article; now it reloads. Details showed a folder's count in the Tags column; now it sits by the name. | ๐ง Merge + fix |
| #484 | Bug (#475) | A search typed while an article was open ran behind it, invisibly. Now a changed search (or Enter) leaves the article for the results - but Tab, arrows or Shift into the box do not, and an open editor is never hidden. | โ Merge |
| #485 | Bug (#476) | Esc closes the topmost Knowledge dialog by clicking its own Close/Cancel, so each dialog tidies up exactly as on a click; capture phase, so the list behind does not also take the Esc. | โ Merge |
| #491 | Feature | Delete on an article's right-click menu in every view, reusing the existing confirmation and archive endpoint; keeps filters, folder and the rest of the selection. | โ Merge |
| #492 | Bug | A folder whose articles were all in the Recycle Bin still could not be deleted. Now it can: the folder row is kept, flagged is_deleted, so recycled articles keep their path and permissions, and restoring one revives the path. |
๐ง Merge + fix |
โ What was good - keep it this way
| What | Why it matters |
|---|---|
| Every PR came with a test that runs the shipped functions in Chrome | They fail on the old code and cannot drift from the real renderers |
| #492 keeps the folder and its ACL rows rather than deleting them | A restricted recycled article stays private, and restores to exactly where it was |
| #492's locking reads and one transaction per delete/restore | A concurrent save into the folder cannot slip past the "is it empty?" check |
| #492 counts unreadable articles and drafts as blocking | A folder never looks empty to someone who cannot see what is in it |
#492 drops is_deleted from the revision token |
A migration script's expected_revision does not conflict just because of the upgrade |
#482 totals from kbFolders, already filtered by the server |
No new endpoint, and a total never counts a folder you cannot open |
| #485 clicks the dialog's own Cancel | No second close path to keep in step with each dialog's tidy-up |
#471 follows the ticket table's splitter pattern (pointer capture, arrow keys, role="separator") |
One way to resize things across the product, accessible by keyboard |
๐ง What was added when merging
All in one follow-up commit, 45dee9c0c.
#492 - folder soft delete
- A readiness probe. As written,
is_deleted = 0went straight into the folder list, permissions, REST and article-save queries. The code lands with the upgrade, the column with Database Verification - so in between, every Knowledge folder request would have failed. Every clause now goes throughknowledgeLiveFolderSql()(includes/knowledge/visibility.php), which adds it only once the column exists;object()reads$row['is_deleted'] ?? 0; delete refuses with "run Database Verification"; restore has nothing to revive. Added to Code traps. - Column position. The PR put
is_deletedfirst in both schema files, so a fresh install would have made it the table's first column. Moved afterinherit_permissions. - Strings. The delete confirmation and the in-app help said a folder "must be empty first"; both now say Recycle Bin articles do not count and restoring one brings the folder back.
#471 - resizable panel
- Save once, not per pixel. The width was written to
localStorageon everypointermove- dozens of writes per drag. Now saved when the drag ends and on each key press. - The test fails loudly. If
initSidebarResize()or#kbSidebarResizeis renamed, the test'spreg_matchfound nothing and it ran against an empty page; it now throws. - Two language keys realigned; a help note added (Folders & views);
knowledge.cssv34 on all three Knowledge pages. - Kept: the hover-mode panel now also stays open on
:focus-within, so tabbing or typing inside it does not collapse it. A small behaviour change, but the right one - documented on the user page.
#482 / #483 - counts
- The two PRs touched the same Details folder row; the conflict was resolved with #483's layout (count by the name) using #482's
folderTotal(), called once per row instead of twice. - The count by the name is no longer bold (it inherited the folder row's weight).
- Both tests matched source with
\nmarkers and failed on a Windows checkout (core.autocrlf); they now normalise line endings first. - Two older tests that extract functions from
knowledge.jsneededfolderTotalin their lists.
#461 - tree scroll
- Up a level and the breadcrumb links now reveal the folder in the tree too, not only the sidebar.
All
- Each PR bumped
knowledge.js?v=from the same base; the merges kept one line, now v86. - The right-click tip in the help now mentions Delete (#491).
Left as it is
- Delete vs Archive. The right-click menu says Delete, the open article's button says Archive; same action, same Recycle Bin. Worth one word in a later tidy-up.
- The name prompt has two Esc handlers - its own and #485's global one. Harmless (both cancel), but one could go.
- Focus after Esc is not returned to whatever opened the dialog. A follow-up.
includes/analyst_lifecycle.phpcounts the folders an analyst owns including deleted ones - a reassignment hint, so the overcount does no harm.
๐งช What was checked
| Test | Result |
|---|---|
Every tests/knowledge-*.php (24 files), on a test install |
pass - except tests/knowledge-visibility/, whose fixtures expect two companies that only exist on my own install (not caused by this batch) |
| Every test on the shared browser harness (39 files) | pass, apart from two ticket tests that fail the same way without these changes |
One harness fix on the way. tests/support/ticket-workspace-browser.php found the page under test by its exact address. Knowledge rewrites its address (?folder=) as soon as it runs, and where the browser's first DevTools answer is slow the page had already done so - so the tree-scroll, back-to-list and search-open-article tests waited for ever. It now matches the page without its query and hash, with a 3-second timeout on each lookup (commit a444981b1).
| tests/knowledge-folder-recycle-bin.php, -browser.php (#492) | pass |
| CI guards (CSS colour, font size, duplicate ids, div balance, web exposure, GET-must-not-write, ...) | pass |
| OpenAPI self-check | pass |
And on screen, before and after on a test install: folder totals in the Cards, Details and Tree views (a folder holding only a subfolder showed 0 before, 1 article after), the Details count by the name instead of under Tags, the panel widened with the arrow keys, and Delete on an article's right-click menu. Deleting a folder whose article is in the Recycle Bin and bringing it back by restoring the article is covered by the two #492 tests above.
See also: Knowledge ยท Folder soft delete: Developer Guide ยท Bugs resolved ยท Pull requests