- Issue created by @Grevil
- π©πͺGermany Grevil
Setting this to "Major" as it is a major regression from 1.x and breaks compatibility with submodules like "rabbit_hole_href".
- πΊπ¦Ukraine Matroskeen πΊπ¦ Ukraine, Lutsk
If we'll look into
\Drupal\taxonomy\Entity\Term
and@ContentEntityType
annotation, we'll see that canonical link exists by default:* links = { * "canonical" = "/taxonomy/term/{taxonomy_term}", * "delete-form" = "/taxonomy/term/{taxonomy_term}/delete", * "edit-form" = "/taxonomy/term/{taxonomy_term}/edit", * "create" = "/taxonomy/term", * },
We also have proof in the functional tests that "Taxonomy" is available in the supported entity types:
$this->drupalGet('admin/config/content/rabbit-hole'); $this->assertSession()->fieldExists('entity_types[user]'); $this->assertSession()->fieldExists('entity_types[node]'); $this->assertSession()->fieldExists('entity_types[taxonomy_term]');
After that, I noticed this in
rabbit_hole_href.module
. No surprise it's not working - canonical link for taxonomy terms is not available anymore:function rabbit_hole_href_entity_type_alter(array &$entity_types) { // @todo Determine the entity types which have rabbit_hole_href enabled as // rh_action, see Drupal\rabbit_hole\BehaviorInvoker, and go through them // instead of only taxonomy_term: // behaviourInvorker->getRabbitHoleValuesForEntityType($entity_type, $bundle); // NOTE: Currently the uri callback is always set, even if redirect is set to // 404 etc.!! $entity_types['taxonomy_term']->setUriCallback('rabbit_hole_href_redirect_uri'); $links = $entity_types['taxonomy_term']->get('links'); unset($links['canonical']); $entity_types['taxonomy_term']->set('links', $links); }
Maybe the unset is not necessary? For example, in one of the core modules this is not happening:
/** * Implements hook_entity_bundle_info_alter(). */ function forum_entity_bundle_info_alter(&$bundles) { // Take over URI construction for taxonomy terms that are forums. if ($vid = \Drupal::config('forum.settings')->get('vocabulary')) { if (isset($bundles['taxonomy_term'][$vid])) { $bundles['taxonomy_term'][$vid]['uri_callback'] = 'forum_uri'; } } }
Let me know if you think that conditions in Rabbit Hole should be different.
- Status changed to Closed: works as designed
over 1 year ago 7:23am 5 July 2023 - π©πͺGermany Grevil
@Matroskeen, thank you! I thought, I'd tested this without rabbit_hole_href enabled! My apologies, I probably forgot to clear all caches, after I uninstalled it...
And thanks for the example from core! I couldn't properly solve this inside π Using this module in Drupal 10 currently breaks the module Active yesterday, as it is currently broken for the newest Drupal version anyway.