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.
The example for hook_views_default_views_alter would cause a fatal error if used with views caching enabled (which in general it is). (The error happens various times, like when reverting views, etc).
Replaced with an example that does the same but shouldn't cause that error to my understanding.
Comment | File | Size | Author |
---|---|---|---|
hook_views_default_views_alter_doc.patch | 506 bytes | hefox | |
Comments
Comment #1
dawehnerlooks fine
Comment #2
hefox CreditAttribution: hefox commentedA note on the documentation is that hook and several others do not mention what files they could be put in and auto loaded. This hook works in the module.views.inc (and likely the .views_default.inc for this one). hook_views_pre_render is another that can work in .views.inc.
Comment #3
dwwAs per an IRC debugging session with Earl, if you do anything fancy in here, you also need to call $view->destroy(). I'll try to give this some love based on my newfound knowledge of how this all works... Stay tuned.
Comment #4
esmerel CreditAttribution: esmerel commentedI'm gonna bet dww doesn't have much time to work on this. I'm going to unassign it, and if anyone can/will take it up, that would be useful :)
Comment #5
hefox CreditAttribution: hefox commentedThere was actually a duplicate of this, #910990: Improve documentation of hook_views_default_views_alter() example that got committed (basically same patch as first I think).
However, the new understanding of views destroy likely should be added. (was trying to remember about views->destory and found the other issue first)
Comment #6
MustangGB CreditAttribution: MustangGB commented