Core deprecated the uri_callback entity type property in drupal:11.4.0; it is removed in drupal:13.0.0. Change record: https://www.drupal.org/node/3575062

The domain entity type still declares it, pointing at Domain::uri(), which returns Url::fromUri($domain->getPath(), ['absolute' => TRUE]), an absolute URL on the domain record's own hostname.

Since #3541558: Remove the remaining plugin annotations from the 4.x branch moved the entity type declaration to a PHP attribute, the deprecation is now triggered at plugin discovery time by the Drupal\Core\Entity\Attribute\ConfigEntityType constructor, so it shows up in every test run that installs the module. With the annotation it only fired when EntityType::getUriCallback() was actually called.

A link template cannot replace the property here: the canonical URL of a domain record is an absolute URL on another host, not a route on the current site.

Proposed resolution:

  • Override toUrl() in Drupal\domain\Entity\Domain so that the canonical relation returns that absolute URL while every other relation falls through to the parent implementation, then remove the uri_callback property.
  • Keep Domain::uri() as the single place that builds the URL, or fold its body into the override.
  • Review the consumers that depend on the canonical relation, in particular the core entity reference label formatter when a domain_access or domain_source reference is rendered as a link.

Testing: add a kernel test asserting that $domain->toUrl('canonical')->toString() still returns the absolute domain URL, and confirm the deprecation is gone from the test output.

This is 4.x only: 3.x supports Drupal 10.2 and 11, where the property is still available.

Issue fork domain-3613276

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

MR !413 opened against 4.x.

The deprecation fired from two places, both now gone: the ConfigEntityType attribute constructor at discovery time, and EntityType::getUriCallback() on each toUrl('canonical') call.

Domain::toUrl() now handles the canonical relation itself and delegates every other relation to the parent. Domain::uri() stays as the single source of URL construction. The override replicates the callback path exactly, including the entity data passed through as options and the configuration entity convention of not setting an explicit language.

On consumers: the entity type has no canonical link template, so toUrl() with no argument still resolves to the edit form. That is the relation the entity reference label formatter uses, so domain reference fields keep linking to the edit form, as before.

New kernel test DomainUrlTest covers the canonical URL, the path prefix, option merging, toLink(), the other link relations, an ID-less record, and the absence of the property on the entity type.

Verified against Drupal 11.4.4: before the change the new test class reports the deprecation from both call sites in every test; after it, the whole domain kernel suite (87 tests) and the three entity reference functional tests pass with no uri_callback deprecation left.

One thing found while writing the test, unrelated and left alone: the collection link template resolves to the route name entity.domain.collection, which the module does not declare (the route is domain.admin), so $domain->toUrl('collection') throws a RouteNotFoundException. Filed as #3613844: The collection link template of the domain entity type points to a route that does not exist.

  • mably committed 69d634e4 on 4.x
    task: #3613276 Replace the deprecated uri_callback entity type property...
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.