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']);
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scor’s picture

The 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).

scor’s picture

dropbydrop’s picture

subscribe

scor’s picture

Issue tags: +sprint
mlncn’s picture

Status: Active » Needs review
FileSize
0 bytes

This should work. Could be done in one line but it's clearer in three.

This could use a test.

klonos’s picture

Hey Benjamin, something must have gone wrong with the upload. The patch is 0 bytes, so you might wanna re-upload please? Thanx in advance ;)

oriol_e9g’s picture

Status: Needs review » Needs work
mlncn’s picture

mlncn’s picture

Status: Needs work » Needs review

I see bytes now! Thanks klonos et al.

Status: Needs review » Needs work

The last submitted patch, 1228872-rdf-default-mappings-override-empty-values-1.patch, failed testing.

klonos’s picture

;)

...I'll give it a spin once you get it to be green.

Anonymous’s picture

Anonymous’s picture

Status: Needs work » Fixed

Since #1869600: Refactor RDF mappings to be inline with the new Entity Field API removes default mappings for entity types, this is fixed.

Automatically closed -- issue fixed for 2 weeks with no activity.