Skip to content

Task Description Article Picker PR Review

Ed Mozley edited this page Nov 28, 2026 · 1 revision

Knowledge articles in a task's Link dialog - PR review

PR #450 by @Dr4inder Β· No issue (extends PR #253) Β· Verdict: merge + fix Β· 5.12.0

A task's description can now link a Knowledge article the same way a Knowledge article can: Link, then the folder icon beside URL, search, pick. Before, linking a task to a How-To meant opening Knowledge in another tab and copying the address. User page: Tasks Β§ Detail Panel.

βœ… What was good - keep it this way

What Why it matters
One picker for both editors - moved out of knowledge.js into assets/js/kb-article-link-picker.js, each editor passing what differs (API folder, the link to insert, whether to show the folder path) No second copy to drift; Knowledge behaves exactly as before
The list is Knowledge's own - api/knowledge/knowledge_articles.php, filtered by knowledgeVisibilitySql() for the signed-in analyst Only articles that analyst may read are offered - company, audience and access list included
The icon only for analysts who may open Knowledge (analystCanAccessModule(..., 'knowledge'), like $taskCanProjects) No button that leads to a refusal
Only six Knowledge strings on the Tasks page, sliced the way tickets/index.php slices Files' The page does not carry the whole Knowledge namespace
Ids kept only if they are safe positive integers, the link built from the id alone Nothing a title contains can reach the href
relative_urls: false, with the reason written down The same description is shown from tasks/table/, calendar/ and timeline/, where TinyMCE's ../knowledge/ would point at tasks/knowledge/
A test that runs the real tasks.js editor setup under a sub-folder install, including the analyst without Knowledge Proves the root-relative link and the gate

πŸ”§ What was added and fixed when merging

1. The status line was escaped the banned way 🟑

The move swapped escapeHtml(status) for box.textContent = status; … box.innerHTML, because tasks.js has no escapeHtml. That trick leaves quotes alone - exactly the pattern the 3.14.0 escape-helper fix removed from 107 helpers. Safe where it was (between tags), but the next person to copy it into an attribute would not be. The shared file now has its own quote-safe kbLinkPickerEsc().

2. Cache-buster ✏️

#448 and this PR both moved knowledge.js to v=76. Merged second, this one ends at v=77.

3. Help ✏️

Tasks' in-app help has a line on linking a Knowledge article from a description (tasks.help.panel_field_desc_kb).

4. The test on a Windows checkout ✏️

tests/task-description-article-link.php found the editor setup by searching tasks.js for "\n}\n\n// ── Who else". A Windows checkout has CRLF line endings, so it threw setup not found. It now folds CRLF to LF first.

Left as it is

  • Drafts are listed, as in Knowledge's own picker - it is analyst-only, and linking to a draft is how a How-To is written alongside the task.
  • Existing links typed in a description are now stored from the site root (/tickets/...) the next time the description is saved, instead of ../tickets/.... They point at the same page; the root-relative form is the one that works from every view.

πŸ§ͺ What was checked

Test Result
tests/task-description-article-link.php (the PR's) 8 passed
tests/knowledge-link-picker-editor.php (changed to load the shared file) 12 passed
tests/task-description-render.php, task-form-embed.php, knowledge-article-links.php, knowledge-permission-badges.php all pass
tests/escape-helpers-quotes.php, tests/web-exposure-guard.php pass

On screen: a task's Link dialog before (URL box only) and after (the folder icon, and the article list it opens). A task in a ticket's Work tab runs the same tasks/index.php, so it gets the same icon.


See also: Tasks Β· Knowledge

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally