Skip to content

Scope the report and theme counts to the sites a user can see - #727

Merged
howdu merged 2 commits into
mainfrom
fix/report-and-theme-site-scope
Oct 2, 2026
Merged

howdu merged 2 commits into
mainfrom
fix/report-and-theme-site-scope

Conversation

@howdu

@howdu howdu commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

A user restricted to one site could read data about every site through the admin reports and theme screens: the publishing and accessibility readiness reports listed all page names, site names, language names and edit links; the demo install health report and the dashboard overview counted every site and page; and theme site counts included sites the user cannot access.

Change

  • Publishing and accessibility reports, the demo install health counts and the dashboard pages/sites counts go through SiteScope::applyForCurrentActor(..., denyWhenMissingActor: true). Asking for an unassigned site returns nothing.
  • Theme site counts (resource query, table, library, card fallback) are scoped. The delete guard still checks usage across every site, and the legacy foundation theme is hidden only when no site at all uses it.
  • Existing tests that ran these actions with nobody logged in now log in as a global admin; no assertions changed.

Tests

New ReportSiteScopeTest and ThemeSiteCountScopeTest plus one demo-health case: scoped user sees one site, global user sees all, no actor sees nothing, and a delete of a theme used only on hidden sites is still blocked. The scoped cases failed on the unmodified code and pass now. Locally: packages/admin/tests 2226 passed; Pint, Rector, PHPStan clean on changed files.

Not covered

BuildPublicRenderSafetyReportAction findings, the ThemeValidation block message (reports the total site count) and ThemeExtensionPage in the marketplace package (unscoped site list and apply-to-all) are unchanged and need their own change.

The publishing and accessibility readiness reports, the demo install health counts, the dashboard overview counts and the theme site counts read every site's data, so a user restricted to one site saw page names, site names, edit links and counts for all of them. They now go through the site scope with deny-when-no-actor; global users still see everything. The theme delete guard still checks usage across all sites, and the legacy foundation theme is hidden only when no site at all uses it.
@howdu
howdu enabled auto-merge (squash) October 2, 2026 16:39
@howdu
howdu merged commit 46eab93 into main Oct 2, 2026
31 checks passed
@howdu
howdu deleted the fix/report-and-theme-site-scope branch October 2, 2026 17:01
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