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.
/**
* Checks if a metatag configuration record is enabled.
*
* @param string $instance
* The configuration instance machine name.
*
* @return bool
* TRUE if the configuration is enabled, or FALSE otherwise.
*/
function metatag_config_is_enabled($instance, $include_defaults = FALSE, $include_global = TRUE) {
if ($include_defaults) {
return (bool) metatag_config_load_with_defaults($instance, $include_global);
}
else {
$config = metatag_config_load($instance);
return !empty($config) && empty($config->disabled);
}
}
This returns TRUE or FALSE
/**
* Check if an individual entity has meta tags defined, or has defaults.
*
* @param string $entity_type
* An entity type.
* @param object $entity
* An entity object.
*
* @return boolean
* TRUE or FALSE if the entity should have a form for or process meta tags.
*/
function metatag_entity_has_metatags($entity_type, $entity) {
...
if (!isset($config_exists[$instance])) {
// This is set to TRUE or false
$config_exists[$instance] = metatag_config_is_enabled($instance, TRUE, FALSE);
}
return isset($config_exists[$instance]);
}
TRUE or FALSE are valid set values (unlike null), so it returns TRUE despite the entity config being disabled
Steps to reproduce
1) install metatags
2) disable user entity
3) view user form
4) see mega tag fieldset
Comment | File | Size | Author |
---|---|---|---|
#1 | 2126157-metatag-metatag_entity_has_metatags-1.patch | 391 bytes | hefox |
Comments
Comment #1
hefox CreditAttribution: hefox commentedComment #2
DamienMcKennaThanks for the patch. Committed!
Comment #3
DamienMcKenna@hefox: I just realized I forgot to give you proper attribution for the commit, sorry :( You are mentioned in the changelog, you just aren't the --author of the commit.
In other news, I keep forgetting to do that :(