Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
views.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Feb 2013 at 15:51 UTC
Updated:
5 Aug 2023 at 08:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #0.0
damiankloip commentedUpdated issue summary.
Comment #0.1
damiankloip commentedUpdated issue summary.
Comment #1
tim.plunkettmodule is spelled wrong
Is this actually needed?
If you're rerolling, make this protected :)
break should be indented two spaces, and have a blank line after
Nice!
Comment #2
damiankloip commentedThanks for the review! Fair points.
Comment #3
dawehnerAweseome patch!
The problem with invoke in general though is that it uses function_exists() first, so you actually can't be sure that the file in views.inc haven't been loaded, as once it's loaded it's loaded, but yeah no idea how to address the problem here.
state() that from the container ;)
Comment #4
damiankloip commentedThanks!
Yeah, I think we are at the mercy of the module handler here.
Not sure what you mean about the state()?
Comment #5
dawehner$this->container->get('state')
Comment #6
damiankloip commentedOh! yeah, sure.
Comment #7
dawehnerThis is ready to go now (with green).
Comment #9
damiankloip commentedOh, there is a nice little bug there, when we are invoking hook_views_query_substitutions we are passing in the query class, but I think we want to pass in the view! Also we should add typing to our implementation in views.module
Comment #10
dawehner#6: 1914256-6.patch queued for re-testing.
Comment #12
damiankloip commentedI think this hook should be removed, as that's used in views_ui and not views. The tests have intentionally not included assertions for hook_views_preview_info_alter and hook_views_ui_display_top_links_alter as these should be covered in views ui?
Comment #13
dawehnerThen let's also adapt the other instances of it, to be more constistent.
Comment #14
dawehnerThis is RTBC now.
Comment #15
damiankloip commentedYep, those last tweaks look good.
Comment #16
catchThis puts the cached/info hooks and the runtime hooks into the same group, which means the info/cached hooks will end up more likely to be loaded on every request rather than less (although sites without views enabled at all could skip all of them).
We don't have any standards for what goes in hook_hook_info() but it was originally for performance (sometimes I put .admin.inc and .install files in apc.filters to keep APC size down given those are extremely low hit-rate files, potentially 'info' hook groups could be added to that). Since it doesn't account for dynamic hooks at all that really seems the only decent use for it apart from some minimal code organization.
Comment #17
dawehnerWhat about using .views_runtime.inc additional to the already existing .views.inc, which should be the static one, which is not needed often.
Comment #18
damiankloip commentedOk, I've added the views_runtime group to the hooks in views_hook_info(), and moved module implementations into this new file.
I haven't moved views_views_query_substitutions yet, Do we think it's best to move that into a views.views_runtime.inc file?
Comment #19
dawehnerYeah that one is totally a runtime hook.
Comment #20
damiankloip commentedYeah, let's add it to a views.views_runtime.inc file.
Comment #22
damiankloip commentedOh dear, using classes when needed is usually a good plan.
Comment #24
damiankloip commentedWe need that back too.
Comment #25
tim.plunkettIt didn't apply due to #1912946: Clean up comments in comment.views.inc node.views.inc user.views.inc, just a quick reroll.
Comment #26
damiankloip commentedAnother reroll after the patch adding ViewsDataCache::clear() got in
Comment #27
xjm#26: 1914256-26.patch queued for re-testing.
Comment #28
xjm#26: 1914256-26.patch queued for re-testing.
Comment #30
webchickI would flip these... most other modules have their run-time equivalents in just "module.views.inc", and their admin stuff in "module.admin.inc". (Maybe "module.views_admin.inc" in this case?) "views_runtime.inc" is very strange, and passes a bunch of implementation details down the stack to "normal" developers.
While the rest of these hooks make sense to run on every view that's shown on the front-end of the site, these two seem like oddball ones out. Shouldn't invalidate_cache be included with data/data_alter?
Also, does analyze belong here? It seems like it's only called from views_ui.module.
Comment #31
damiankloip commentedI'm not sure about the flipping, people are used to their data being stored in module.views.inc, it's not really admin data, as it's for the views_data that is used when executing views.
Catch suggested putting the runtime hooks into another file, but really this is optionally too. We can look at changing the name of this, but I think that is quite fitting for it.
Good point about the analyze and invalidate_cache hooks, they could definitely move into the .views.inc file too. hook_views_analyze is invoked in views_ui and node modules in core.
Here is a reroll and moving those 2 hooks. Oh, and sorry, the interdiff is missing the views_invalidate_cache move - Got carried away making changes half way through a rebase :)
Comment #32
xjmhook_views_analyze()andhook_views_invalidate_cache()are only invoked during Views administrative operations, so they are not needed as frequently as the Views runtime hooks. They'd be better grouped with the other hooks.No strong opinion on the labels for the groups.
Edit: Sorry, crossposted. I tend to accumulate a ton of half-written comments on Friday mornings. ;)
Comment #33
xjmFiled #1962704: Document hook_views_analyze().
Trying to think of a better name for
views_runtime. These are the Views execution hooks (#1810590: Improve naming and documentation to clarify hook execution order for exciting details). Maybe we could call the groupview_renderorview_executionor something?Comment #34
dawehnerI really like the view_execution name, because it refers to the ViewExecutable.
Comment #35
damiankloip commentedOk, let's go for views_execution.
Comment #36
effulgentsia commented+1 to
views_execution(plural).Comment #37
effulgentsia commentedLol. xpost.
Comment #38
dawehner+1.00000000000001
Comment #39
webchickOk, this looks good.
Alex explained that although hook_views_data() and their ilk are called less frequently, they're definitely defined much more frequently than any of the executable hooks, so it makes sense for them to take up the primary "views" namespace.
I also struggled a bit with "executable" as the adjective here, since that can also mean "something that can be killed" ;) whereas "runtime" is more explicit what's meant. But xjm pointed out that the underlying API name is "ViewsExecutable," so keeping these in sync is useful. Makes sense.
Committed and pushed to 8.x. Thanks!
Moving to the Views queue for the change notice there.
Comment #40
dave reidThis seems really odd. As a module developer, I have a hook that does not have 'views_executable' in the name, but now I have to figure out that I cannot just place it in my modulename.views.inc file. This breaks the current pattern of core by just putting everything into the one namespace for consistency and DX. Both hook_token_info() and hook_tokens() are placed in modulename.tokens.inc even though one is the registry of information, and one is the 'executable'. I would hate it as a module developer if I had to remember each time as a best practice to have both pants.token_info.inc and pants.token_executable.inc.
Comment #41
dave reidtl;dr: It's a lot easier for a module developer to remember 'This is a Views hook, it should go in modulename.views.inc' rather than 'This should either go in modulename.views_execution.inc or modulename.views.inc.'
I feel very -1 on this change even though it's been committed.
Comment #42
webchickI don't disagree on the DX impact, but this split was specifically asked for by catch in #16, for performance.
Comment #43
dave reid:/
Comment #44
dawehnerDon't nail be down on that, but afaik you couldn't place the hook_views_FOO_BAR hooks into .views.inc, so at least that's not worse then in D7.
I agree that it's bad for DX, but seriously, we included probably more then 2000 lines of code or even more, without ever have the need for it.
Comment #45
xjmActually, what we should do is document the appropriate file on each hook in
views.api.php.Comment #45.0
xjmUpdated issue summary.
Comment #46
damienmckennaMoving to the core issue queue.
Comment #58
lendudeFiled the requested follow up from #45, #3375847: Document in views.api.php for each hook in which include file they can be placed .
Discussed with @xjm and @longwave, issuing a CR now would serve no purpose, so closing this as fixed.
Comment #59
xjmRestoring original title and removing the now-irrelevant tag. Thanks!