Originally this issue was going to be "Re-name hook_views_pre_view()" based on a discussion with @dawehner, but the more I looked into it, the more I realized that a lot of the hook and method names could probably be changed:

In ViewExecutable::preview()

  1. Display set
  2. ViewExecutable::preExecute()
    1. Arguments set.
    2. hook_views_pre_view()
    3. Display handler's preExecute()
  3. Display handler's preview() method. In DisplayPluginBase, this runs ViewExecutable::render():
    1. ViewExecutable::execute()
      1. ViewExecutable::build() called:
        1. hook_views_pre_build()
        2. Query built.
        3. Displays attached.
        4. hook_views_post_build()
      2. hook_views_pre_execute()
      3. Query executed or data retrieved from cache.
      4. hook_views_post_execute()
    2. Pre-rendering done for exposed form, pager, and style plugin.
    3. hook_views_pre_render() executed for modules and then themes.
    4. Display rendered.
    5. Post-rendering for exposed form.
    6. hook_views_post_render() executed for modules and then themes.
  4. ViewExecutable::postExecute()

In ViewExecutable::executeDisplay()

  1. Display set.
  2. ViewExecutable::preExecute()
    1. Arguments set.
    2. hook_views_pre_view()
    3. Display handler's preExecute()
  3. Display handler's execute() method. In DefaultDisplay this runs ViewExecutable::render():
    1. ViewExecutable::execute()
      1. ViewExecutable::build() called:
        1. hook_views_pre_build()
        2. Query built.
        3. Displays attached.
        4. hook_views_post_build()
      2. hook_views_pre_execute()
      3. Query executed or data retrieved from cache.
      4. hook_views_post_execute()
    2. Pre-rendering done for exposed form, pager, and style plugin.
    3. hook_views_pre_render() executed for modules and then themes.
    4. Display rendered.
    5. Post-rendering for exposed form.
    6. hook_views_post_render() executed for modules and then themes.
  4. ViewExecutable::postExecute()

Comments

xjm’s picture

Issue tags: +VDC
xjm’s picture

One thing that would probably help a lot would be for the pre- and post- "build" and "execute" hooks to have the word "query" in their names.

hook_views_pre_execute() happens during ViewExecutable::execute() which is way after and somewhat decoupled from ViewExecutable::preExecute(), which really had me scratching my head for awhile. So maybe the first step is:

  • hook_views_pre_execute() renamed to hook_views_pre_query()
  • hook_views_post_execute() renamed to hook_views_post_query()
xjm’s picture

Another note, actually changing hook names should be postponed until after the merge, but I'm leaving the issue open for now to get more feedback.

xjm’s picture

Another confusing thing is the way that ViewExecutable::executeDisplay() calls the display handler's execute() which goes back and calls ViewExecutable::render() which calls ViewExecutable::execute().

xjm’s picture

And I find myself wondering what methods we could make protected to make everything a bit less overwhelming.

xjm’s picture

Project: VDC » Drupal core
Issue summary: View changes

Updated issue summary.

xjm’s picture

Project: Drupal core » VDC
Status: Active » Postponed

Okay, actually marking this postponed lest someone come along and think that I'm saying to make any of these changes now. :)

dawehner’s picture

@xjm
I agree #4 is hard to understand. Also preview() is calling display::preview().

Maybe we could get rid of some of these abstractions, what about removing custom execute/preview/render methods on the display and just keep executeDisplay? This probably needs research and better test coverage first. It's though still cool to have control from your display handler, as some (like ctools context) are pretty awesome flexible based on that.

hook_views_pre_execute() renamed to hook_views_pre_query()
hook_views_post_execute() renamed to hook_views_post_query()

I'm wondering whether people could mix this up with building the query, i guess no. In general i really like this renaming.
Then we could also rename hook_views_pre_view to hook_views_pre_execute as that's what its doing.

xjm’s picture

Well, we could also do:

hook_views_query_pre_build()
hook_views_query_post_build()
hook_views_query_pre_execute()
hook_views_query_post_execute()
Maybe we could get rid of some of these abstractions, what about removing custom execute/preview/render methods on the display and just keep executeDisplay? This probably needs research and better test coverage first. It's though still cool to have control from your display handler, as some (like ctools context) are pretty awesome flexible based on that.

If this is possible, it sounds like a great idea. It could make the DX better (think of how overwhelming the view object is when you dpm() it, and how much redundancy there is) and possibly also help a bit with our performance and memory footprint. I'd agree though that we'd need more test coverage first.

dawehner’s picture

This hooks are probably used for much more then change the query, because you have the full $view object available so you can alter around,
prefix with query maybe let people think that these hooks shouldn't be used for other things.

xjm’s picture

Yeah, that's a fair point. The earlier suggestion is probably better then.

xjm’s picture

Project: VDC » Drupal core
Version: » 8.x-dev
Component: Documentation » views.module
xjm’s picture

Status: Postponed » Active
Issue tags: +DX (Developer Experience)

Since I've had conversations with three different people over the past week trying to explain Views' internal terminology, I think it's probably time to tackle this.

xjm’s picture

Issue summary: View changes

Updated issue summary.

xjm’s picture

So renaming the hooks is no longer in scope during the beta. However, adding this documentation to the views documentation group still is something we should do. I guess this needs to get split into two issues now -- one for the docs, and a postponed one for renaming the hooks. (I wonder if it is possible to "rename" the hooks in 8.1.x, and provide BC by still invoking the old hooks, but marking them deprecated? hm.)

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Needs work

This seems to still be valid.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.