Closed (fixed)
Project:
Features
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
29 Nov 2010 at 19:08 UTC
Updated:
11 Apr 2014 at 01:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
hefox commentedComment #2
Grayside commentedI've tried various ways of applying one or two patches to test this, and I'm not getting all the needed changes applied. Either there is a broken patch, or I need simpler instructions :)
I didn't like the documentation for features_get_alter_state() so I took a stab at rewriting it. Would have made a patch, but
Comment #3
hefox commentedI was probably manually editing the patch or had some other patches, or some sort if sillyness that prevented it applying. I'll remake the patch, hopefully tonight.
Comment #4
goron commentedHere's a rebuilt patch that applies cleanly to the 6.x-1.1 release and current dev (there were a few small changes to one of the functions).
Comment #5
hefox commentedGoing to update this patch
Comment #6
hefox commentedPatch depends on #1390848: Centralize the call to hook_features_api().
What it does is add two new potential, non-required keys to hook_features_api
This way a module can indicate if there is an alter hook, and what it is (and if an export needs to define it -- truefully don't alter_info it being used outside of hook_node_info, though there may be other core like that).
Adding some mess with an global to say whether to run an alter, not really happy about that.
Comment #7
hefox commentedPatch does not deal with the features_get_default bug anymore, focusing on the feature request.
Comment #8
hefox commentedNeed to update it for image styles
Comment #9
mpotter commentedI like most of the ideas in #6, but I'm wondering why the Node exportable needs the new inline alter added to it. Doesn't the existing features_get_default call drupal_alter for the default_hook already? Why does Node need to be different/special?
Comment #10
hefox commentedfeatures_get_default is just a helper function for features to help it generically call default hooks by module and only used 'for real' for hooks that features itself has provided (fields, filters). hook_node_info (and image), while given features support via features itself, are core hook called by core functions ( _node_types_build, image_styles()), so cannot add any hook that is not already there in core. :-/
Comment #11
mpotter commentedConfused. Still seems like features_get_default is already calling drupal_alter('node_info', ... and thus the "inline" drupal_alter call is not needed, so I'm not sure you answered my question.
Comment #12
hefox commentedhook_node_info is a hook used by core. Core does not use features_get_default to call it, core uses _node_types_build.
Comment #13
hefox commentedComment #14
hefox commentedI still reallly don't like the global/etc. doing in the patch, but it's sorta a screwy situation.
Comment #15
Grayside commentedYou could replace it with a wrapper function that hits a statically cached value. That would avoid bad global mojo and perhaps simplify debugging.
Comment #16
hefox commentedFixing type in alter hook for image (image_style => image_styles).
Meh, wrapper function is unnecessary overhead
Comment #17
mpotter commented+++ b/includes/features.node.inc
@@ -86,6 +87,10 @@ function node_features_export_render($module, $data, $export = NULL) {
+ $output[] = ' global $features_alter;'; ¶
whitespace at end of line
Also failed to apply to latest 7.x-1.x-dev version.
Otherwise I think the approach is good.
Comment #18
hefox commentedHere's an reroll against a fresh pull of 7.x-1.x so hopefully it applies (with the white space removed)
Comment #19
Sarenc commentedThe last patches weren't applying against the 6.x-1.x-dev of Feb 22/2012 so I re-rolled one.
I didn't see an /includes/features.image.inc file so I ignored that bit.
Comment #20
mpotter commentedI'm still not happy with the way the alter hook for node is implemented. The use of the global features_alter variable just seems kludgy. For the sake of trying to get the really important piece of this patch into Features soon, here is a reduced patch for the 7.x-1.x-dev version that removes the global and the node alter and just contains the core code to add the new alter hook information to the api.
Comment #21
hefox commentedsounds good to me
Comment #22
mpotter commentedCommitted f7447af
Comment #23
mpotter commentedAlso, the node stuff should go to a new issue if we can figure out a better way.
Comment #24
hefox commentedComment #25
scottrigbyMerged f7447af to 6.x-1.x & patched for review.
Comment #26
hefox commentedCan't do this till #1390848: Centralize the call to hook_features_api() is backported.
Comment #27
mxmilkiib commentedI'm looking to export a forum setup to a feature.
I've patched Features 6.x-1.x-dev with #23 on #1390848: Centralize the call to hook_features_api() and #25 here, but I'm not getting 'Forum topic' in the Content types.
Is there a further step I should be taking? Or am I viewing this the wrong way, or simply barking up the wrong tree? Thanks for any advice.
Comment #28
damienmckennaBump for testbot.
Comment #29
hefox commentedThis is not going backported I think, so kicking this back to 7.x to add the hook_node_info_alter that was part of the original patches
Comment #30
hefox commentedComment #31
marcusx commentedThanks!
I had a content type named "Show" and needed to swap the
t()function for adding some context so I can avoid the translation of the content type name. Works like expected. Here is my hook as an example for a potential use case.Comment #32
hefox commented