This will abstract out PHP into an array of steps, which can then be called.
Design is flexible, and contrib modules can add more stuff.
Likely candidates for this include index.php stuff, menu_execute_active_handler(), and theme().
One of the advantages of this is that we can now do fun stuff like hook_steps_alter(), allowing modules to make changes to core Drupal logic where needed.
An example use case would be if I wanted not to print theme('page', $return), but instead, output it in some other format. Or perhaps I want to change the site maintenance response from site maintenance to access denied. Or perhaps I want to not bother with blocks for anonymous users. Or override menu_execute_active_handler with my new system, which accepts a different format of input than GET. The possibilities are endless, and this API can be used nearly anywhere!
Edit: Patch attached. Code removed for increased readability.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | steps_0003.patch | 1.85 KB | cwgordon7 |
| #1 | includes/steps.inc | 13.62 KB | cwgordon7 |
Comments
Comment #1
cwgordon7 commentedOk. It is way past my bedtime, and I am so not dealing with adding files to CVS when CVS hates me and is laughing at me right now. So I have attached the new file; it is meant to be named steps.inc and placed in the includes/ directory.
Setting to code needs review.
Comment #2
Anonymous (not verified) commentedI'll take a look at this tomorrow. I will be running a performance test against this patch, as I am curious as to what sort of extra processing is going to be involved.
My initial concerns were discussed with cwgordon7 on irc.
Comment #3
steven jones commentedYeah, the performance hit could be huge as I'm guessing that you'd want this called on every page. Needs a benchmark.
Comment #4
Anonymous (not verified) commentedInitial results, stock configuration, following instructions/guidelines here: http://drupal.org/node/79237
And after applying the patch:
493ms +/- 23.7ms std. deviation before patch
507.58ms +/- 27.4ms std. deviation after patch
No noticeable performance hit or improvement.
Comment #5
cwgordon7 commentedSo roughly a 15 millisecond loss, give/take ~25 milliseconds. Question is now, is this worth it?
Comment #6
Anonymous (not verified) commentedNo, @cwgordon7. Basically the test was inconclusive, there is no measurable loss or gain in performance. Which is a good thing.
Comment #7
Crell commentedI am honestly not in favor of this methodology, not for performance reasons as much as complexity. There are ways to make PHP's pipeline dynamic that do not involve writing PHP with lots and lots of brackets around it, which is basically what this is doing. I'd much rather establish a clearer pipeline with key "bend" points than trying to abstract the PHP language itself. That's going to lead to alls sorts of array spaghetti.
Comment #8
dmitrig01 commentedWhy is
in steps.inc, while the
hook_step_typesis defined in system module?There needs to be more calling of functions. It seems you made a couple of tweaks to
steps_executein order to specifically accomodate the page. This is not generalized enough.Next criticsm:
in steps.inc, steps_execute:
I see several problems with this code. First and foremost, this is just STUPID. Why not include the bootstrap in index.php? You are obfuscating code. We might as well use runkit for something like this :P.
Can you stick in a few more examples? Like, the menu system - access callback, wildcard replacements, run page callback, theme('node') for ndoes, etc.
This is ugly -
'arguments' => array('$return'),Comment #9
Anonymous (not verified) commented@Crell I feel that it is overly complex as well, and don't see myself /ever/ wanting to use it.
Comment #10
cwgordon7 commentedcnw then.
I have some ideas about how to fix this up and make it into a nicer API. I need time to do this though.
dmitrig01 also suggested the idea of a drupal_call() function that would allow hook_function_alter()'s to take place.
E.g.
This will allow for added awesomeness. This can either be in addition to steps or separate.
Comment #11
pwolanin commented#10 seems like an interesting idea - though I don't know how this would fit in with registry.
Basically - you could imagine this as a rewrite of module_invoke() - where module_invoke() allows you to _alter?
Note, however, chx has pointed out to me that with PHP5, we should just avoid using call_user_func_array(0 by having a lon list of args that default to NULL.
Comment #12
cwgordon7 commentedOh yes, awesome idea! Module_invoke() should definitely allow for alterations too! We can even do funky stuff like hook_hook_{hook}_alter! It'll be awesome!
Comment #13
sunI think this is obsolete due to the new page rendering process using drupal_render() and hook_page_alter().