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.
Some modules (i18n_menu, entity_menu_links) extend the menu_links table schema with new columns. In order to persist those new attributes, I had to patch the includes/features.menu.inc file. Patch to follow.
This is definitely not an extensible way to solve this problem, but the available hooks don't seem to be enough to solve this problem.
The patch at #2 makes no assumptions about the extra fields and is completely extensible.
Your feedback is welcome.
Comment | File | Size | Author |
---|---|---|---|
#17 | features-menu_link_query_tag-1931512-15.patch | 1.02 KB | plach |
Comments
Comment #1
infojunkiePatch attached.
Comment #2
infojunkieHere is an alternative patch that does not hard-code new columns in the query. Instead, it uses a query tag to allow for query alteration. Third-party modules are free to implement
hook_query_features_menu_link_alter
to extend the query and return extra fields to be exported.Comment #3
alexweber CreditAttribution: alexweber commentedlooks good
Comment #4
infojunkieHere's a fuller description of the use case.
Comment #5
pivica CreditAttribution: pivica commentedI do not see how will patch in #1 help with customized attribute that is also missing in features export - and without it i18n menu items will not work correctly.
Approach in #2 is cool but we then need that hook_query_TAG_alter() some where that will add missing attributes - should it go to features or i18n module?
Anyway I needed same customized fix for D6, I just added that attrib in features_menu_link_load() and problem fixed for i18n menu items.
We should maybe even consider adding customized property by default in features_menu_link_load() because it is core menu property?
Comment #6
infojunkiePatch #1 explicitly adds
language
anduuid
attributes tofeatures_menu_link_load()
. Patch #2 adds a query tag that allows you to alter the query and add any field you like, in your own module.Comment #7
pivica CreditAttribution: pivica commentedYeah I get all that and it is correct.
I am just saying that this patches will not help with customized property and users will still not be able to export i18n menu items because of that. Users should not create custom module to allow this behavior - so this is either i18nmenu or features bug - but similar approach like in this patches can fix this also. I guess customized property export should go into separate issue.
Comment #8
mpotter CreditAttribution: mpotter commentedI'm going to mark patch #2 as RTBC because I think that's a better approach and then the i18n module should implement the hook to properly add the needed fields to the query.
Comment #9
infojunkieThanks mpotter, that was my thinking too.
Comment #10
hefox CreditAttribution: hefox commentedinfojunkie's git authorship name is kratib? That through me off "WTf, did I attribute the wrong person?"
Comment #11
infojunkiehefox, yes it is. My previous username on d.o :-) Thanks for the commit!
Comment #12
infojunkieThis thread exists to allow saving localization information for menu links within features. Please read the original post to understand the context.
The Features maintainers have committed a patch that allows 3rd party modules to override the loading of menu links as they are being serialized. To complete the cycle, it is now up to i18n_menu to override the loading of menu links with the required attributes, namely
language
andcustomized
.Patch attached.
Comment #13
Jose Reyero CreditAttribution: Jose Reyero commentedNice, committed, thanks.
Comment #14.0
(not verified) CreditAttribution: commentedUpdate description for patch #2
Comment #15
plachIt seems this commit accidentally reverted the commit for patch #2 happened in #10.
Here's a reroll. Setting to RTBC as the change was already reviewed/approved.
Comment #16
plachComment #17
plachNow for reals :)
Comment #18
hefox CreditAttribution: hefox commentedthanks, hopefully this will stick this time. oops.
Comment #19
ckngTested with i18n_menu:
7.x-2.0:
'customized' & 'language' are not exported.
7.x-2.x-dev (001c0e47e):
'customized' & 'language' are exported but the language bit is wrong, all are 'und', where it should be 'en, 'en-gb' or 'es' in my case.
Comment #20
ckngLooks like the export is correct, the language field somehow have been changed to 'und' after going through features export. Possible another features bug?
To reproduce,
- have menu set to Translate and Localize
- add language specific menu items
- export via features, menu items languages are all reset to 'und'
Comment #21
hefox CreditAttribution: hefox commentedOpen a new issue please