Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be nice to expose the node comments in a property.
Comment | File | Size | Author |
---|---|---|---|
#9 | entity-add-comments-property-1414688-9.patch | 1.24 KB | jsacksick |
#3 | 1414688_add_node_comments_property.patch | 1.49 KB | jsacksick |
#1 | 1414688_add_node_comments_property.patch | 1.4 KB | jsacksick |
Comments
Comment #1
jsacksick CreditAttribution: jsacksick commentedHere is the proposed patch.
Comment #2
fagoLet's better say "for getting the comments of a node".
What are the access restrictions for this property? I guess there is "access comments" or something like that.
Then, this needs to be provided by the comment module integration. Also, it's computed so we should set 'computed' to TRUE.
Comment #3
jsacksick CreditAttribution: jsacksick commentedComment #4
fagoStill needs to be moved to comment module integration.
That's an entity access callback, I doubt the arguments match.
Comment #6
drunken monkeyTagging according to #1832348: Add a computed property to load the comments of a node and #949372-4: Port issue views to Search API so we can have a performant backend.
Comment #7
MrHaroldA CreditAttribution: MrHaroldA commented@fago: any pointers in how to fix the access callback? I used the code in a hook_entity_property_info_alter(), without the access callback and it works perfectly (in our case).
I added this to prevent indexing unapproved comments:
And this to mark the node for re-indexing after a commit has been submitted, or updated:
Comment #8
jsacksick CreditAttribution: jsacksick commentedI'm not sure what the access callback should actually do.
Should it return TRUE if you have access to at least one comment ? or should we check for all of the associated comments?
In any case this will lead to the load of the associated comments which is IMO not really optimal !
Comment #9
jsacksick CreditAttribution: jsacksick commentedI moved the patch to the comment module but I removed the access callback, for sure the arguments won't match, I started to write a custom access callback but then I realized as noted in #8 that it wasn't really useful.
Comment #10
askibinski CreditAttribution: askibinski commentedTested the patch at #9, works fine for getting a related "comments" field for indexed nodes in search api. Works great, but I didn't test any access callbacks for comments because we don't have unapproved comments.
Comment #11
noahadler CreditAttribution: noahadler commentedsubscribe
Comment #12
frankye CreditAttribution: frankye commented#9: entity-add-comments-property-1414688-9.patch queued for re-testing.
Comment #13
checker CreditAttribution: checker commentedI'm using patch #9 without problems to index comments in search api. I also did not test access issues.
Comment #14
clemens.tolboomPatch from #9 _plus_ latest 7.x-1.x-dev made our solr_search index comments.
We had to enable both 'Comments' from this patch and 'Comment: *' fields on admin/config/search/search_api/index/node_search/fields ... to have search result for comment strings the fields were added to our search views.
As we are now 1.5 years further I'm not sure we still need 'access callback'. Isn't that covered by entity.module
$entity_info['comment']['access callback'] = 'entity_metadata_comment_access';
?Set to RTBC for another developers review.
Comment #15
drummI tried this out for #949372: Port issue views to Search API so we can have a performant backend and it looks good. We want to index the comment bodies.
Comment #16
drumm(tag)
Comment #17
drummFor Drupal.org, I had to go ahead and commit this to our deployment repository. We do want to get back to an unhacked module.
Comment #18
frankye CreditAttribution: frankye commentedI created a simple module sandbox to integrate comments and node ...for me it works: https://drupal.org/sandbox/frankye/2066873
Comment #19
drumm9: entity-add-comments-property-1414688-9.patch queued for re-testing.
Comment #20
drummLooks like the 7.x-1.x branch is not passing tests.
Comment #21
lukus9: entity-add-comments-property-1414688-9.patch queued for re-testing.
Comment #22
fagoSince the security issue for lists of referenced entities got fixed - time for this one. Thanks, committed!