Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Administrators can no longer disable the meta tag form on the admin page.
Steps to reproduce
- Download and enable the beta5 release of the metatag module.
- Browse to /admin/people/create and observe the meta tags fieldset at the bottom of the form.
- Browse to /admin/config/search/metatags and disable the User configuration.
- Clear all caches
- Browse to /admin/people/create and observe the meta tags fieldset is still at the bottom of the form.
Proposed resolution
It appears that a new function (metatag_config_is_enabled) was introduced between beta4 and beta5 in commit: 140a3243d60a1935a2776df6ac459c1dbb713494 and the metatag_entity_has_metatags function was refactored to use the new function. However, the return function was not updated to handle the response from the new function.
Remaining tasks
Create a patch to update the return statement
Comment | File | Size | Author |
---|---|---|---|
#1 | 1958992-metatag-cannot-disable_1.patch | 381 bytes | douglasmiller |
Comments
Comment #1
douglasmiller CreditAttribution: douglasmiller commentedAttached patch
Comment #2
DamienMcKennaThis is working from an incorrect assumption that a site maintainer wouldn't want the meta tag fields to show, even if there wasn't a configuration specifically for that entity type. Instead, what you're looking for is this: #1286270: Option to disable meta tags per entity/bundle/object
Comment #3
douglasmiller CreditAttribution: douglasmiller commentedI must be interpreting the configuration page incorrectly. I was operating on the assumption that disabling the User configuration would disable metatags for the User entity. I have done some testing with the 7.x-1.x branch and have observed that my assumptions are wrong.
Here are the steps that I performed to verify using the HEAD of the 7.x-1.x branch:
However, the 7.x-1.0-beta4 version of metatag behaves very differently.
Here are the steps that I performed to verify using the tag 7.x-1.0-beta4:
Based on your earlier comment, I am going to assume that the beta4 version is not behaving correctly. The current functionality in beta5 does make the most sense to me.
The metatag_entity_info_alter function adds 'metatags' => TRUE to the user entity, therefore there should be meta tags for the user entity. Since the User configuration is disabled, it is logical that the Global configuration is inherited.
I am still confused about the patch that I posted. The metatag_entity_has_metatags will always return TRUE if the entity supports metatags, even though the metatag_config_is_enabled function returns FALSE. Returning isset($config_exists[$instance]) will always be TRUE since the introduction of the metatag_config_is_enabled in commit 140a3243d60a1935a2776df6ac459c1dbb713494. The previous implementation would only set $config_exists[$instance] to a non NULL value if there was an enabled configuration.
Sorry for the wall of text, I just want to verify that I understand how the module is supposed to function.
Comment #4
Dave ReidYes, the assumption is that the admin/config/search/metatags/config is the default meta tags configuration only, not 'does this entity type support meta tags or not'. Disabling records there should only disables the defaults.