Updated: Comment #7
Problem/Motivation
Features integration for microdata has a couple issues:
- On features update microdata must be explicitly re-added.
- 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
Comment #1
Volx commentedThis 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.
Comment #2
Volx commentedThis might also solve #1514762: Microdata must be added explicitly to Features on update
Comment #3
ianthomas_ukIn 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?
Comment #4
Volx commentedPatch #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.
Comment #5
ianthomas_ukThis 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.
This saves a double call to _microdata_load_mapping, which is good.
These changes look good. I'll test locally and hopefully then RTBC.
Comment #6
ianthomas_ukTested locally - this fixes my features
Comment #7
fenstratConfirming 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.
Comment #8
fenstratComment #10
das-peter commentedThanks - committed :)