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
Because the RDF module merges in the default mappings when there is no value, the user cannot remove the default mappings that are declared for an entity. The default mappings can be overriden, but not removed completely.
For example, someone may want to use RDF UI to remove the User mappings so that Google Rich Snippets will work for a piece of content. However, if they delete the mappings, they will just be reinserted on rdf_mapping_save:
function rdf_mapping_save($mapping) {
// In the case where a field has a mapping defined in the default entity
// mapping, but a mapping is not specified in the bundle-specific mapping,
// then use the default mapping for that field.
$mapping['mapping'] += _rdf_get_default_mapping($mapping['type']);
Comment | File | Size | Author |
---|---|---|---|
#8 | 1228872-rdf-default-mappings-override-empty-values-1.patch | 742 bytes | mlncn |
#5 | 1228872-rdf-default-mappings-override-empty-values-1.patch | 0 bytes | mlncn |
Comments
Comment #1
scor CreditAttribution: scor commentedThe ability to provide defaults is still a good feature IMO, and valuable in most cases. So the API should allow for a flag to disable this overriding... maybe something like rdf_mapping_save($mapping, $use_defaults = TRUE).
Another alternative is to make sure that providing an empty array does not lead to using the defaults, and that no empty attribute gets added in the HTML (e.g.
datatype=""
). I think I prefer this option better (i.e. no API change).Comment #2
scor CreditAttribution: scor commentedsee also #1229974: Allow for empty mappings (work around pending core fix)
Comment #3
dropbydrop CreditAttribution: dropbydrop commentedsubscribe
Comment #4
scor CreditAttribution: scor commentedComment #5
mlncn CreditAttribution: mlncn commentedThis should work. Could be done in one line but it's clearer in three.
This could use a test.
Comment #6
klonosHey Benjamin, something must have gone wrong with the upload. The patch is 0 bytes, so you might wanna re-upload please? Thanx in advance ;)
Comment #7
oriol_e9gComment #8
mlncn CreditAttribution: mlncn commentedComment #9
mlncn CreditAttribution: mlncn commentedI see bytes now! Thanks klonos et al.
Comment #11
klonos;)
...I'll give it a spin once you get it to be green.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedCurrently, the patch in #1869600: Refactor RDF mappings to be inline with the new Entity Field API would fix this for D8.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedSince #1869600: Refactor RDF mappings to be inline with the new Entity Field API removes default mappings for entity types, this is fixed.