The patch in #2041287: Convert $node->nid to $node->id() and $node->isNew() was a bit to zealous and converted a $node->nid too many.

In \Drupal\comment\Plugin\views\field\NodeNewComments::preRender() the $node variable is a simple object from a databse result with only an nid and num_comments property.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JvE’s picture

olli’s picture

Component: views.module » comment.module
Status: Active » Needs review
Issue tags: +VDC, +Needs tests

Nice find. I think we need a test here.

Status: Needs review » Needs work

The last submitted patch, 1: fix_nid_access_in_prerender-2505879-1.patch, failed testing.

RavindraSingh’s picture

Without tests.

RavindraSingh’s picture

Status: Needs work » Needs review
RavindraSingh’s picture

Here, I am adding a patch which includes tests in DefaultViewRecentCommentsTest.php file. I am not sure how to write the tests here, Adding the tests in existing file.

/**
 * @file
 * Contains \Drupal\comment\Tests\Views\DefaultViewRecentCommentsTest.
 * Contains \Drupal\comment\Tests\Views\NodeNewComments.
*/

Here I am not sure if we can add more tests into single file.

RavindraSingh’s picture

Status: Needs review » Needs work

Moving back to needs work.

Needs guidelines for writing tests.

andypost’s picture

+++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
@@ -141,7 +141,7 @@ public function preRender(&$values) {
-        foreach ($ids[$node->id()] as $id) {
+        foreach ($ids[$node->nid()] as $id) {

should be $node->nid as patch #1 does

geertvd’s picture

Added some tests for this

The last submitted patch, 9: call_to_undefined-2505879-9-test.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: call_to_undefined-2505879-9-complete.patch, failed testing.

Status: Needs work » Needs review
borisson_’s picture

Fixed a small nitpick in the patch. (Short array syntax).

This has tests so removing the tag.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Since I didn't really change anything with the patch I added and test still pass, I feel I can RTBC this issue.

andypost’s picture

+1 rtbc

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

@borisson_ the short array syntax is a recommendation rather than a standard.

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes.Committed f85c0c1 and pushed to 8.0.x. Thanks!

  • alexpott committed f85c0c1 on 8.0.x
    Issue #2505879 by RavindraSingh, geertvd, borisson_, JvE: Call to...

Status: Fixed » Closed (fixed)

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