Knowledge Folder Lock Badges PR Review - edmozley/freeitsm GitHub Wiki
Knowledge folder lock badges - PR review
PR #448 by @Dr4inder ยท No issue ยท Verdict: merge ยท 5.12.0
In Knowledge, a ๐ beside a folder's name is meant to say this folder has its own permissions, the same as it does on an article. On folders it said something else. User page: Knowledge.
What you saw
| Folder | Before | After |
|---|---|---|
| Follows the folder above, but was set to Restricted before inheritance was switched on | ๐ - although the restriction no longer applies | no lock |
| Has its own rules, open to everyone | no lock - although it does not follow its folder | ๐ |
| Has its own rules, restricted | ๐ | ๐ |
| Follows the folder above | no lock | no lock |
What was wrong
Ticking Use the same permissions as the folder above keeps the folder's own Open / Restricted setting (is_restricted) stored, so it comes back if inheritance is switched off again - but while inheritance is on, that setting does nothing. Every folder renderer drew the lock from is_restricted, so it showed a setting that was asleep and missed an open folder with its own rules. Articles already used inherit_permissions, so the two disagreed in the same list.
It was four places, not one: the sidebar tree, the tree layout, the details layout, and the cards/list rows.
โ What was good - keep it this way
| What | Why it matters |
|---|---|
Uses the inherits field api/knowledge/folders.php already sends |
No API or schema change |
Number(f.inherits) === 0 |
Right whether the value arrives as 0 or "0" |
| All four folder views changed; the tooltip reuses the article badge's Has its own permissions | One meaning for the lock in the whole module, no new strings |
A TRAP: comment that is_restricted stays stored but inactive |
The next person does not "fix" it back |
tests/knowledge-permission-badges.php runs the shipped renderers in Chrome, every layout and the sidebar |
It fails on the old code (13 folder checks) and cannot drift from the real functions |
| Access checks, stored permissions and the API untouched | A display fix that cannot change who sees what |
๐ง What was added when merging
Nothing - merged as it was.
Left as it is
- The Permission exceptions dialog still draws its lock from
is_restricted. That is right there: the dialog only lists things with their own rules, so its lock means Restricted. - A long folder name in the sidebar is cut short with "โฆ", and the lock goes with it. That was so before this PR, for every long name.
- The string
knowledge.folders.restrictedis no longer used; it is left in the locale files.
๐งช What was checked
| Test | Result |
|---|---|
tests/knowledge-permission-badges.php (the PR's) |
40 passed |
tests/knowledge-folder-navigation.php |
6 passed |
tests/escape-helpers-quotes.php, tests/web-exposure-guard.php |
pass |
And on screen, on a test install with four ZZ folders, one of each kind: before, the inheriting folder showed the lock and the open one with its own rules did not; after, the other way round.
See also: Knowledge ยท Bugs resolved