Problem/Motivation

In a multilingual site, the entity links in the admin lists point at the unprefixed (site default language) path, so following one leaves the current language. On the orders list at /fr/admin/booking/orders the order title links to /admin/booking/orders/{id} instead of /fr/admin/booking/orders/{id}, while the operations links in the same row (Confirm, Cancel, Archive) do keep the prefix, so one row mixes two languages.

The cause is core EntityBase::toUrl(), which forces the link's language to the entity's own language for every link relation except collection, add-page and add-form: $options += ['language' => $this->language()]. yoyaku_transaction is not translatable and an order is saved in the site default language, so the link is built as a default-language URL and LanguageNegotiationUrl::processOutbound() adds no prefix. The operations links are built with Url::fromRoute(), which passes no language option and therefore follows the current language.

To reproduce: enable a second language with URL path prefixes, place a booking, then open the orders list under the second language's prefix and hover an order title.

Proposed resolution

Pass an explicit language option so the negotiator falls back to the current URL language. ['language' => NULL] is enough: toUrl() merges options with the union operator, which keeps a key that already exists even when its value is NULL, and the negotiator's guard is !isset($options['language']).

Every admin list that links an entity through toUrl() is affected, not just the orders list: yoyaku_order (OrderOverviewForm, OrderOverviewController, OrderOperationsTrait), yoyaku_ui (BookingsForm, BookingOverviewForm, SlotOverviewForm, ResourceSlotsController, SlotTiersController, ResourceCategoriesController) and yoyaku_placement (VenueInventoryController).

Remaining tasks

  • Add the language option to every entity link in an admin list.
  • Cover it with a functional test that loads a list under a language prefix and asserts the links keep it.

User interface changes

Admin list links keep the current language instead of switching back to the site default.

API changes

None.

Issue fork yoyaku-3613327

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

Issue summary: View changes

mably’s picture

Status: Active » Needs review

  • mably committed 5bf2ab67 on 1.x
    fix: #3613327 Admin list links built with toUrl() drop the language...
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.