While testing #2422123: should entity view hooks be triggered unconditionally in node_view, term_view and user_view pages? we came across an interesting problem in Open Atrium. In the latest OA version we have the ability to embed full nodes as "related content" within other nodes. This includes any comments made to the embedded node. We found that when the comments on the embedded node exceed the comments per page, the pager is not actually shown. It is shown on the node with the comments, but not the node that has the embedded node with comments (hope that makes sense).

Basically, what I found is that the Drupal pager system is using the $pager_page_array global variable to keep track of pagers on the page. In the case where there are multiple pagers on the page the comment panes in ctools fail because they don't set the $element of the pager, always assuming it is zero (the first pager).

The pager_default_initialize() function that sets up the global array is called from the query set up in comment_get_thread() in the comment module. But it doesn't have any way to pass back which $element index was just created. So in the ctools panes we just use the max(array_key) of the global $pager_page_array.

Patch coming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpotter’s picture

Status: Active » Needs review
FileSize
1.42 KB
SocialNicheGuru’s picture

Chris Matthews’s picture

The 5 May 2015 patch to node_comment_wrapper.inc and node_comments.inc applied cleanly to the latest ctools 7.x-1.x-dev and if still applicable needs to be reviewed.

Checking patch plugins/content_types/node_context/node_comment_wrapper.inc...
Hunk #1 succeeded at 47 (offset 4 lines).

Checking patch plugins/content_types/node_context/node_comments.inc...
Hunk #1 succeeded at 94 (offset 3 lines).

Applied patch plugins/content_types/node_context/node_comment_wrapper.inc cleanly.
Applied patch plugins/content_types/node_context/node_comments.inc cleanly.

Note, the previous comment states:

conflicts with https://www.drupal.org/node/2433923#comment-10070732