Problem/Motivation

In views_hook_info() the hook_views_analyze is assigned to the group => 'views', therefore all the implementation of hook_views_analyze should be declared in a .module file or in a .views.inc file. Node module implementation of hook_views_analyze is located in node.views_execution.inc, so it never executed

Proposed resolution

Move node_views_analyze() in node.views.inc

Remaining tasks

Write a patch

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

willzyx created an issue. See original summary.

willzyx’s picture

Status: Active » Needs review
FileSize
5.33 KB

moreover this issue shows that there is not test coverage for this hook in the node module

willzyx’s picture

Issue tags: +Needs tests

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.

LoMo’s picture

The patch no longer even came close to applying, but I think the issue is still valid. I've taken the liberty of attempting a re-roll.

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.

Chi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests
Related issues: +#2925477: Revise node_views_analyze message

The patch works for me.

there is not test coverage for this hook in the node module

I am not sure if this should be included here. This issue is just about wrong location of this hook. Since the hook implementation needs revising I propose we handle this in #2925477: Revise node_views_analyze message.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks for working on this!

This issue is a bugfix, so it does need test coverage that proves the bug is fixed. We should add a test that fails against HEAD and passes when combined with the test that moves the hook implementation. Test coverage is a core gate, so we don't postpone it to followup issues even if the state of the test coverage in HEAD is not great.

So, setting "Needs work" to add automated test coverage. Thanks!

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.

g-brodiei’s picture

Assigned: Unassigned » g-brodiei

Will try to work on this test coverage.

g-brodiei’s picture

Giving it a try on my first test coverage with #7patch together.
I'm not sure if the asserting method for analyze message is the best approach, if there are any better suggestion, I am all ears!

Setting to needs review.

g-brodiei’s picture

Status: Needs work » Needs review
g-brodiei’s picture

Issue tags: +Bug Smash Initiative

adding bug smash initiative tag

Lendude’s picture

Status: Needs review » Needs work

@g-brodiei nice! Great first effort!

  1. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +use Drupal\views\Views;
    

    Unused use

  2. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    + * Tests the bug fix for node_views_analyze hook.
    

    This should explain what the test tests, not reference why it was added. 'Tests node_views_analyze().' should be fine.

  3. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +  ¶
    +  /**
    +   * Modules to be enabled.
    +   * ¶
    +   * @var array
    

    Lots of trailing white space in the test, that needs to go.

  4. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +  public static $modules = ['views', 'views_ui', 'node_test_views'];
    

    this should be protected

  5. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +  protected function setUp($import_test_views = TRUE) {
    

    on 9.1 this needs :void

  6. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +    $this->drupalCreateContentType(['type' => 'page']);
    ...
    +    // Create two nodes.
    +    for ($i = 0; $i < 2; $i++) {
    

    Why are we creating nodes? Is that needed to analyse the View?

  7. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +  public function testNodeViewsAnalyze() {
    

    Needs a docblock to describe that is being tested

  8. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +    $this->assertSession();
    

    This doesn't do anything, we can take it out

  9. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +    /**
    +     * Will SUCCESS if contains proper error message.
    +     * Will FAIL if bug patch not applied.
    

    No need to explain this, that is what assertions do (and we don't use /** comments only //)

  10. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,88 @@
    +     * @see node_views_analyze() at core/modules/node/node.views.inc.
    

    If the method has a docblock pointing to this, there is no need to mention it here

Lendude’s picture

Oh and please add a test-only patch (with only the test, not the fix) so we can see that the fix actually works.

g-brodiei’s picture

@Lendude, thank you for reviewing! Submitting a test to fail patch and fixed patch with suggestions.

For the suggestion, there is one I didn't change.
4. I can't run test if $module was set to protected, shown on the error message returned, so remaining as public.

Also removed useless override of function setUp() since there isn't any node needed to be created.

g-brodiei’s picture

Assigned: g-brodiei » Unassigned
FileSize
2.42 KB

Add interdiff for review.

Status: Needs review » Needs work

The last submitted patch, 21: node_views_analyze_is-2586013-fail.patch, failed testing. View results

g-brodiei’s picture

Status: Needs work » Needs review

Setting back to needs review, the failing test was meant to fail as the patch wasn't combined.

longwave’s picture

Version: 8.9.x-dev » 9.1.x-dev
Status: Needs review » Needs work
Issue tags: -Needs tests

This is looking pretty good, thanks for working on it. The $modules property changed from public to protected in 9.0.0. Patches should be produced for the latest version first and then backported if necessary, so bumping this to 9.1.x.

  1. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,49 @@
    +  /**
    +   * Modules to be enabled.
    +   *
    +   * @var array
    +   */
    

    This can just be

      /**
       * {@inheritdoc}
       */
    
  2. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,49 @@
    +  public static $modules = ['views_ui', 'node_test_views'];
    

    In Drupal 9 this needs to be protected, please see https://www.drupal.org/node/2909426

  3. +++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
    @@ -0,0 +1,49 @@
    +   * {@inheritDoc}
    

    inheritDoc -> inheritdoc

    (annoyingly, the PHPStorm autocomplete gets this wrong for Drupal!)

Vidushi Mehta’s picture

Status: Needs work » Needs review
FileSize
11.63 KB
695 bytes

Added a patch with the above mentioned changes by #25.

g-brodiei’s picture

Status: Needs review » Reviewed & tested by the community

Thank you Longwave for reviewing and Vidushi Mehta for creating the patch for 9.1!
Going to set this to RTBC!!

catch’s picture

Status: Reviewed & tested by the community » Needs work

I don't think we should be recommending panels here - can we at least change the message to recommend layout builder? I know that introduces a bit of a conflict with #2925477: Revise node_views_analyze message.

pameeela’s picture

Status: Needs work » Needs review
FileSize
11.65 KB
1.63 KB

Updated patch and interdiff.

longwave’s picture

+++ b/core/modules/node/node.views.inc
@@ -0,0 +1,52 @@
+        $ret[] = Analyzer::formatMessage(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use layout builder.', ['%display' => $display->display['display_title']]), 'warning');

Sorry to nitpick but in the module list this is called Layout Builder, I think we should follow the same capitalisation?

pameeela’s picture

I wondered about that but panels was lowercase so I followed that convention. Easy to change. Patch attached with title case, the committer can choose which one :)

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community
g-brodiei’s picture

Wow, the progress moved so fast on this one today! I forgot to reload the page and went generating patches after work just then, and it's done already when I reloaded the page LoL. AWESOME!!!!

larowlan’s picture

Adding review credits

  • larowlan committed db13a84 on 9.1.x
    Issue #2586013 by g-brodiei, pameeela, Vidushi Mehta, willzyx, LoMo,...
larowlan’s picture

Title: node_views_analyze() is never executed because it is in the wrong inc file » [backport] node_views_analyze() is never executed because it is in the wrong inc file
Version: 9.1.x-dev » 9.0.x-dev

Fixed on commit:

diff --git a/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
index cc94caa819..057d70cbfc 100644
--- a/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
+++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
@@ -9,7 +9,7 @@
  */
 class NodeViewsAnalyzeTest extends NodeTestBase {

-   /**
+  /**
    * {@inheritdoc}
    */
   protected static $modules = ['views_ui', 'node_test_views'];

Committed db13a84 and pushed to 9.1.x. Thanks!

Moving to 9.0.x for a possible backport once freeze is over.

Setup an 8.9 test run

Sidenote: this was my 1000th commit to Drupal core 🎉

larowlan’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +Needs reroll
jonathanshaw’s picture

I believe this needs rerolled and working versions for both 8.9 and 9.0

ayushmishra206’s picture

Rerolled for both 8.9 and 9.0. Please Review.

ayushmishra206’s picture

Status: Patch (to be ported) » Needs review

The last submitted patch, 39: 2586013-39.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

g-brodiei’s picture

Thanks for helping on rerolling ayushmishra206!

The $modules test property was made protected in D9, but should be public for D8.

as mentioned here by xjm 112.

+++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
@@ -0,0 +1,47 @@
+   * {@inheritdoc}
+   */
+  protected static $modules = ['views_ui', 'node_test_views'];
+

should be made public for 8.9, and protected for 9.

Would love another set of eye to review too!

g-brodiei’s picture

Reroll for 8.9.x, add interdiff for 39-43

g-brodiei’s picture

Tried rerolling #31 patch for 9.1.x following the guide on reroll patch, no conflicts after rebasing on step 9, so I requested a retest on the #31 patch against 9.1.x.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

  • larowlan committed 186b0a3 on 9.0.x
    Issue #2586013 by g-brodiei, pameeela, ayushmishra206, Vidushi Mehta,...

  • larowlan committed bd8685e on 8.9.x
    Issue #2586013 by g-brodiei, pameeela, ayushmishra206, Vidushi Mehta,...
larowlan’s picture

Title: [backport] node_views_analyze() is never executed because it is in the wrong inc file » node_views_analyze() is never executed because it is in the wrong inc file
Version: 9.0.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs reroll

Backported 186b0a3 and pushed to 9.0.x. Thanks!

Fixed on commit

diff --git a/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
index cc94caa819..057d70cbfc 100644
--- a/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
+++ b/core/modules/node/tests/src/Functional/Views/NodeViewsAnalyzeTest.php
@@ -9,7 +9,7 @@
  */
 class NodeViewsAnalyzeTest extends NodeTestBase {

-   /**
+  /**
    * {@inheritdoc}
    */
   protected static $modules = ['views_ui', 'node_test_views'];

Backported to 8.9.x as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.