From f85c0c140dab0a8f4e4172779050dbe9594f09af Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 12 Aug 2015 19:20:38 +0100 Subject: [PATCH] Issue #2505879 by RavindraSingh, geertvd, borisson_, JvE: Call to undefined method stdClass::id() --- .../Plugin/views/field/NodeNewComments.php | 2 +- .../src/Tests/Views/NodeCommentsTest.php | 41 +++++ .../views.view.test_new_comments.yml | 163 ++++++++++++++++++ 3 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 core/modules/comment/src/Tests/Views/NodeCommentsTest.php create mode 100644 core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_new_comments.yml diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php index 4ed2ba809b3..55d1613541c 100644 --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -141,7 +141,7 @@ class NodeNewComments extends NumericField { ':timestamp2' => HISTORY_READ_LIMIT, )); foreach ($result as $node) { - foreach ($ids[$node->id()] as $id) { + foreach ($ids[$node->nid] as $id) { $values[$id]->{$this->field_alias} = $node->num_comments; } } diff --git a/core/modules/comment/src/Tests/Views/NodeCommentsTest.php b/core/modules/comment/src/Tests/Views/NodeCommentsTest.php new file mode 100644 index 00000000000..c83ffaedf2d --- /dev/null +++ b/core/modules/comment/src/Tests/Views/NodeCommentsTest.php @@ -0,0 +1,41 @@ +drupalGet('test-new-comments'); + $this->assertResponse(200); + $new_comments = $this->cssSelect(".views-field-new-comments a:contains('1')"); + $this->assertEqual(count($new_comments), 1, 'Found the number of new comments for a certain node.'); + } + +} diff --git a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_new_comments.yml b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_new_comments.yml new file mode 100644 index 00000000000..e32997603c3 --- /dev/null +++ b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_new_comments.yml @@ -0,0 +1,163 @@ +langcode: en +status: true +dependencies: + module: + - comment + - node + - user +id: '2505879' +label: '2505879' +module: views +description: '' +tag: '' +base_table: node_field_data +base_field: nid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 0 + display_options: + access: + type: perm + options: + perm: 'access content' + cache: + type: tag + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: '' + query_tags: { } + pager: + type: full + style: + type: table + row: + type: fields + fields: + title: + id: title + table: node_field_data + field: title + entity_type: node + entity_field: title + alter: + alter_text: false + make_link: false + absolute: false + trim: false + word_boundary: false + ellipsis: false + strip_tags: false + html: false + hide_empty: false + empty_zero: false + settings: + link_to_entity: true + plugin_id: field + relationship: none + group_type: group + admin_label: '' + label: Title + exclude: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_alter_empty: true + click_sort_column: value + type: string + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + new_comments: + id: new_comments + table: node + field: new_comments + relationship: none + group_type: group + admin_label: '' + label: 'New comments' + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + set_precision: false + precision: 0 + decimal: . + prefix: '' + suffix: '' + link_to_comment: true + entity_type: node + plugin_id: node_new_comments + filters: { } + sorts: { } + title: '' + header: { } + footer: { } + empty: { } + relationships: { } + arguments: { } + display_extenders: { } + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: 1 + display_options: + path: 'test-new-comments'