Problem/Motivation

BookingUiHooks::pageAttachments() attaches the stylesheet that gives the Booking item its toolbar icon, gated on whether the current user holds access toolbar or administer yoyaku. That guess is wrong in both directions.

The permission does not exist on a site without the toolbar module, and user 1 is answered yes to every permission there is, so the account most likely to be looking is served a toolbar stylesheet on a site that has no toolbar. On every page, at that, rather than only on pages that have one, which is what hook_page_attachments() means.

Proposed resolution

hook_toolbar_alter() runs inside the toolbar element's own pre-render, so it cannot be reached without the module and never fires on a request that is not building a toolbar. The toolbar's own cacheability then covers it, and the user.permissions cache context this had to add goes away with the guess. currentUser was injected for that hook alone, so the constructor takes nothing now.

Booking also moves to weight -50, to the front, before the sections a site is built with: taking a booking is the work the site exists to do, opened many times a day, while Structure and Appearance are opened while building it and rarely after. A definite weight rather than 0, which ties with Configuration and leaves the order to a comparison of translated titles. Kessai's Payments takes -30 and follows it.

Remaining tasks

None. ToolbarIconTest covers the pair of strings nothing else reads: that the class the stylesheet writes is the class core generates from the link's plugin id, and that the library lands on the administration tray and nowhere else.

User interface changes

The Booking item moves to the front of the toolbar, before Content and the other sections a site is built with. The icon is unchanged.

Also here

A metrics job, gated on $CI_COMMIT_TAG and allow_failure, ported from audit_trail. docs/metrics.md is a snapshot, regenerated deliberately rather than kept in step by every merge request, and nothing measured it on a release either. It gates nothing: it prints a diff for a maintainer to read, measured from git archive so that cloc does not count the Drupal the pipeline builds underneath the project. The generator gains METRICS_DATE so the re-measurement reproduces the committed page's date.

API changes

None.

Data model changes

None.

AI-Generated: Yes (Claude Code was used to help draft this issue summary and to write the code and tests on the merge request. I reviewed and ran the work myself before posting it.)

Issue fork yoyaku-3622847

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review
mably’s picture

Title: Attach the Booking toolbar icon from the toolbar, not from every page » Attach the Booking toolbar icon from the toolbar, move Booking to the front, and measure the codebase on a tag
Issue summary: View changes

  • mably committed c638deed on 1.x
    fix: #3622847 Attach the Booking toolbar icon from the toolbar, move...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.