Skip to content

Only build the package management forms for visitors who can use them - #1837

Merged
Seldaek merged 2 commits into
mainfrom
perf/skip-unusable-forms
Sep 8, 2026
Merged

Only build the package management forms for visitors who can use them#1837
Seldaek merged 2 commits into
mainfrom
perf/skip-unusable-forms

Conversation

@Seldaek

@Seldaek Seldaek commented Sep 7, 2026

Copy link
Copy Markdown
Member

viewPackageAction built and createView()'d the add-maintainer, remove-maintainer, transfer and delete forms for every visitor, including anonymous ones. The template already renders each of them behind the matching voter grant (view_package.html.twig:103,173,191,211), so for the overwhelming majority of the ~4.5M package page views per APM period all four were discarded unrendered.

createView() is not free either: RemoveMaintainerRequestType uses an EntityType, so materialising its choice list runs a real query against the package's maintainers (UserRepository::getPackageMaintainersQueryBuilder).

Gating on the same grants the template uses keeps the rendered output identical while dropping four form builds and one query from almost every package page view.

Verification

composer phpstan clean, full suite green. The existing testCreateMaintainer / testRemoveMaintainer / testTransferPackage tests already cover the granted side end-to-end (they crawl the page and submit the forms); the new test covers the other half — that an anonymous visitor gets none of the four, and a maintainer still gets all four.

viewPackageAction built and createView()'d the add-maintainer, remove-maintainer,
transfer and delete forms for every visitor, including anonymous ones. The template
already renders each of them behind the matching voter grant, so for the overwhelming
majority of the 4.5M package page views per APM period all four were discarded
unrendered.

createView() is not free either: RemoveMaintainerRequestType uses an EntityType, so
materialising its choice list runs a real query against the package's maintainers.

Gating on the same grants the template uses makes the rendered output identical while
dropping four form builds and one query from almost every package page view.
@Seldaek
Seldaek merged commit 19c0dbe into main Sep 8, 2026
8 checks passed
@Seldaek
Seldaek deleted the perf/skip-unusable-forms branch September 8, 2026 08:59
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.

2 participants