Updated: Comment #7

Problem/Motivation

Features integration for microdata has a couple issues:

  1. On features update microdata must be explicitly re-added.
  2. Exporting features give an error Notice: Undefined offset: 1 in microdata_mappings_features_export() (line 32 of sites/default/modules/contrib/microdata/microdata.features.inc)

Proposed resolution

Correct microdata's features integration to remove issues.

Remaining tasks

Test patch.

User interface changes

None.

API changes

None.

Original report by @Volx

When exporting a feature I get the following notice (which in fact is an error):

Notice: Undefined offset: 1 in microdata_mappings_features_export() (line 32 of sites/default/modules/contrib/microdata/microdata.features.inc).

It is possible that this error only appears when using a recent version of Features. The error is thrown because Microdata expects a name as the array key, but the name is only provided as value. The fix is simple enough and should be backwards compatible (I have not tested with Features 1.x though).

Comments

Volx’s picture

StatusFileSize
new2.72 KB

This seems to be a symptom of a larger problem with the feature export, where features were not correctly rendered, not displayed as overridden and not reverted.

Here is another patch trying to fix Features integration. Again this might only be an issue with version 2 of the Features API.

Volx’s picture

ianthomas_uk’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev

In my testing using drush and features 7.x-2.x, $data passed to microdata_mappings_features_export is an array of values, rather than an array of keys, so #0 is the correct fix for that. My only concern would be how it was ever written to look at the keys in the first place - presumably there is some scenario where it is correct to be pulling the data from the keys (edit: after looking through the documentation it all just refers to $data being an array of machine names, so it looks like this was always broken).

#1 makes much larger changes, but I don't really understand why they are being made or what the impact is. Are you able to provide more info about the changes that have been made and why please?

Volx’s picture

Patch #0 fixes the notice, but Features integration remains broken. As far as I recall Features were not correctly exported, patch #1 is fixing that for me using Features 2.x. What I can't say is what the impact is when using Features version 1.x.

ianthomas_uk’s picture

  1. +++ b/microdata.features.inc
    @@ -12,7 +12,7 @@ function microdata_features_api() {
    -      'default_hook' => 'microdata_mappings',
    +      'default_hook' => 'microdata_mappings_defaults',
    

    This is one of two possible fixes, as I explain in more detail on #1514762: Microdata must be added explicitly to Features on update. Given that Features exports aren't working at all I'm less concerned about upgrading old Features now.

  2. +++ b/microdata.features.inc
    @@ -26,14 +26,12 @@ function microdata_mappings_features_export($data, &$export, $module_name = '')
    -    if ($microdata_mapping = _microdata_load_mapping($entity_type, $bundle_type)) {
    -      $export['features']['microdata_mappings'][$entity_type . '-' . $bundle_type] = $microdata_mapping;
    -    }
    +    $export['features']['microdata_mappings'][$entity_type . '-' . $bundle_type] = $entity_type . '-' . $bundle_type;
    

    This saves a double call to _microdata_load_mapping, which is good.

These changes look good. I'll test locally and hopefully then RTBC.

ianthomas_uk’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Tested locally - this fixes my features

fenstrat’s picture

Title: Error on feature export » Issues with features export
Issue summary: View changes
Related issues: +#1514762: Microdata must be added explicitly to Features on update

Confirming the RTBC status of the patch in #1.

I've updated the issue summary as #1 fixes a couple issues.

Like others I've not tested this with features 1.x, however it works fine with features 2.x.

fenstrat’s picture

Issue summary: View changes

  • das-peter committed 26d1f0a on 7.x-1.x authored by Volx
    Issue #2092365 by Volx: Fixed Issues with features export.
    
das-peter’s picture

Status: Reviewed & tested by the community » Fixed

Thanks - committed :)

Status: Fixed » Closed (fixed)

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