Skip to content

Issue 373 All Companies Changes CMDB Starters

Ed Mozley edited this page Nov 17, 2026 · 3 revisions

🏒 #373 All companies: Changes, CMDB and Starters & leavers showed only the last company picked

GitHub #373, reported by @cloudcogsio Β· Change Management, CMDB, Starters & leavers, Watchtower Β· fixed in 5.5.0 (#2993)

What you saw

On a multi-company install, pick All companies in the header switcher. Tickets, Problems and Tasks widen to every company you can reach. Change Management did not: it showed exactly the changes of the company you had picked before, with nothing on screen to say so. The CMDB and Starters & leavers did the same. So did two cards in Watchtower, Domains and Projects, while the ticket cards beside them widened.

What was wrong

Every company-scoped list chooses between two filters in includes/tenancy.php:

activeTenantFilter($conn, $analystId, 'c');      // ALWAYS one company - the one last picked
activeTenantReadFilter($conn, $analystId, 'c');  // one company, or every company you can reach under All companies

"All companies" is a view, not a company: the session keeps the company you picked last as well, so writes still have one company to land in. That is why activeTenantFilter() answers with that company - and why a list that uses it quietly ignores the All companies view. The helper's own comment has warned of this since GH #356 (Assets β†’ People):

 * TRAP: a new LIST READ that keeps activeTenantFilter() quietly shows only the
 * last company picked under "All companies"

It was several places, not one:

Place Read Now
Change list (api/change-management/list.php) activeTenantFilter widens, each card names its company
Change calendar (get_calendar_changes.php) activeTenantFilter widens
Ticket β†’ Link to change picker (same list.php) the selected company the ticket's company (?for_ticket=)
Watchtower Domains and Projects cards (includes/watchtower_queries.php) activeTenantFilter widen, as their modules already did
CMDB browse and search activeTenantFilter stay on one company, and say so
Starters & leavers register, a person's cases activeTenantFilter stay on one company, and say so

Why some lists widen and others say "one company"

The rule Ed set on #356 decides it: the switcher decides what you see; a record's own company decides what you can pick (Assets and All companies design). A list is safe to widen only if everything you can do from a row follows that row's company.

  • Changes pass. Opening a change checks the change's own company (analystCanAccessChange()), and the change's only company-specific picker, the linkable tickets, already follows the change's company. Types, statuses, priorities and analysts are shared by every company.
  • CMDB does not, yet. A CI's detail panel scopes its parent, children and references to the selected company (api/cmdb/get_object.php), and the parent and relationship pickers search the selected company. Widen the browse list and you could open a CI from company B whose relationships come up empty, or link it to a CI in company A.
  • Starters & leavers does not, yet. Opening a case checks the selected company, and a case's asset lookups (api/starters/lookups.php) load the selected company's statuses - the same open step as the asset list.

So CMDB and Starters stay on one company, exactly like the asset list since 5.4.0, and now say which with a note under All companies:

Showing Default only. The CMDB shows one company at a time, even under All companies - pick a company at the top of the page to see another.

oneCompanyNoteName() (includes/tenancy.php) gives the page the company's name, or '' when there is nothing to explain (the view is off, or there is only one company).

A picker follows its record, not the switcher. The ticket's Link to change picker read the same list.php. Widening it would have offered other companies' changes, which ChangesService::linkTicket() refuses to link. It now sends for_ticket and lists the ticket's own company. In principle that also covers a ticket opened from another company than the one picked (by a direct link, say), which would have been offered the picked company's changes, none of them linkable - that case was not tried on screen.

The fix

// api/change-management/list.php
if ($forTicket > 0) {
    // the ticket's company (after analystCanAccessTicket)
} else {
    [$tenantSql, $tenantParams] = activeTenantReadFilter($conn, $analystId, 'c');
}
$showCompany = $forTicket === 0 && isActiveTenantAll($conn);   // each card names its company

The Tickets help that lists what All companies widens is corrected in all 9 languages; it still said changes stayed on one company. While there, the change card's assignee name, which was inserted without escaping, is escaped.

πŸ“ Files

File Change
🟣 api/change-management/list.php activeTenantReadFilter(), company_name + show_company, ?for_ticket=
🟣 api/change-management/get_calendar_changes.php activeTenantReadFilter()
🟣 includes/watchtower_queries.php Domains and Projects cards widen
🟣 includes/tenancy.php oneCompanyNoteName(); the opted-in list on activeTenantReadFilter() updated
🟑 assets/js/change-management.js The company on each card; assignee escaped
🟑 assets/js/inbox.js The Link to change picker sends for_ticket
πŸ”΅ cmdb/index.php, starters/index.php The one-company note
βšͺ lang/*/cmdb.php, lang/*/starters.php, lang/*/tickets.php The note, and the corrected help, in 9 languages
🟒 tests/all-companies-lists.php 17 checks with a throwaway company

How it was verified

Reproduced first on a test install with a second company: under All companies, the change list showed only the Default company's change; the calendar the same.

tests/all-companies-lists.php (test install only; it adds a company, two changes and two domains and removes them): 17 passed - All companies lists both changes and names their companies; one company lists only its own, without names; the Link to change picker lists the ticket's company under All companies and with another company picked; the calendar widens; the Watchtower Domains card counts every company under All companies with another company picked last (the case @cloudcogsio confirmed on 5.4.1: 34 domains listed, the card said none); the note names the selected company and is absent with one company picked. Control: on the old code 5 fail, including the picker and the Domains card (1 of 2).

Then on screen, with a forged session on the test install: the change list shows both changes, one marked Default and one ZZ Screen Co; CMDB and Starters & leavers show the note.

What this means for you

Update to 5.5.0. Under All companies, Change Management (list and calendar) and Watchtower's Domains and Projects cards show every company you can reach. CMDB and Starters & leavers still show one company, and now tell you which. Nothing changes with a single company picked, or on a single-company install.

For developers: a new list read uses activeTenantReadFilter() only when every action from a row follows that row's company; otherwise keep activeTenantFilter() and show oneCompanyNoteName(). A picker scopes to the record it is attached to, never to the switcher.

Related: All companies ticket view Β· Assets and All companies design Β· All companies design history Β· #356 Assets β†’ People

FreeITSM

Getting Started

Modules

Multi-tenancy (planned)

Responses to feedback

Blue sky thinking

Bugs resolved

Pull requests

Links

Clone this wiki locally