I recently upgraded from 4.4.2 to 4.5.1, and have noticed that the poll block no longer displays the "add new comment" or "# comments" link. This is (was) important to me, as I usually ask for comments whenever someone chooses the negative option. Any idea where and why this went? You can still get to the comment form in a roundabout way ("other polls", choose your poll, whammo), but that's far too many clicks and intellect points.

Comments

rooey’s picture

I had the same problem going from 4.4 to 4.5 - i still see it in 4.5.2 :(

There is *some* info on comment issues here: http://drupal.org/node/11366

I didn't find any of them solved this particular issue tho.

junyor’s picture

So, not even the "add new comment" link is showing up? I just loaded the poll module and that shows fine. However, the current comment count doesn't show correctly in the block.

This is what I've seen so far:
1) poll_block calls poll_view
2) poll_view calls poll_view_voting, which outputs the poll choices
3) for blocks, poll_view calls link_node, which calls hook_link('node') in each module. For all other poll displays, the theme does the call to link_node (via node_view)

I'm guessing poll_view is where the problem is. I'll keep looking at it.

junyor’s picture

Changing the call to link_node on line 438 in poll.module (in poll_view) to:

<?php>
$links = link_node($node, $teaser);

seems to solve the problem. I'm trying to look now at the history of link_node to see why that fixed it. That's the same parameters that the call in theme_node uses.

junyor’s picture

Trying again with correct PHP tags. :)

Changing the call to link_node on line 438 in poll.module (in poll_view) to:

$links = link_node($node, $teaser);

seems to solve the problem. I'm trying to look now at the history of link_node to see why that fixed it. That's the same parameters that the call in theme_node uses.

junyor’s picture

StatusFileSize
new762 bytes

The change to theme_node was done as part of http://drupal.org/node/9287. Other than theme_node, poll_view is the only function that calls link_node directly.

Attached is a patch to fix the function call in poll_view to send the correct parameters.

morbus iff’s picture

Confirmed Junyor's patch. Excellent (note: take my confirmation with a grain of salt. One of my previous patches caused a grievous bug for 4.5.2 tracker.module, and I should not be trusted anymore <g>).

morbus iff’s picture

(His patch is currently in use at gamegrene.com, running 4.5.1).

jeremy’s picture

Seems to work like a charm -- thanks. :)

moshe weitzman’s picture

please submit a patch for HEAD as well (if needed). link_node() no longer exists so this patch is no help for HEAD

junyor’s picture

Note: The attached patch is a good solution for 4.5.2. For HEAD, all hook_link functions need to have their parameter list updated to make sure they're using $teaser and not $main. Same goes for node_link. Additionally, we should think about adding a theme function to handle hook_block links (if one doesn't already exist).

junyor’s picture

Assigned: Unassigned » junyor
junyor’s picture

@moshe: I don't think a patch for HEAD to fix this bug will be needed, as the erroneous function call was removed. Has anyone tested the poll module on HEAD to see if this problem exists there?

dries’s picture

Committed to HEAD.

gábor hojtsy’s picture

Assigned: junyor » gábor hojtsy
StatusFileSize
new1.72 KB

Dries actually comitted the fix to 4.5, but this is still buggy in HEAD. A patch attached which fixes the behaviour. Simply 1 needs to be passed on the teaser value to get the proper comment (and other type of links), since the poll block is kind of a teaser.

This patch also renames $main to $teaser, where appropriate to follow latest Drupal conventions. Without this rename, poll_view() gets a $teaser parameter, and then tries to use $main. This might also apply to 4.5, but since the value of $teaser is never used from then on, it is not much of a problem, just some unneccessary code. I have not removed it from poll_view_results() and poll_view_voting(), to keep the familiary looking param list, although $teaser is not utilized there.

Note: someone might check the Drupal code for $main, since as this patch shows it was renamed to $teaser at some places, but not all.

dries’s picture

This update seems to bring all core modules in line. However, several contributed modules behave differently or have not been updated accordingly. I compiled a list of modules that use $main instead of $teaser:

$ grep -r "\$main" * | grep "_view(&" | awk -F ":" '{print $1}'
modules/event/event.module
modules/image/image.module
modules/filestore2/filestore2.module
modules/bookreview/bookreview.module
modules/lanparty/lanparty.module
modules/survey/survey.module
modules/mail_archive/mail_archive.module
sandbox/geek/catalog.module
sandbox/gordon/patches/02_event_multi_location.patch
sandbox/jseng/drupal4blog/modules/poll.module
sandbox/killes/event.module
sandbox/killes/catalog/catalog.module
sandbox/matteo/custom done types/announce.module
sandbox/matteo/custom done types/biography.module
sandbox/matteo/custom done types/choir.module
sandbox/matteo/custom done types/group.module
sandbox/matteo/custom done types/media.module
sandbox/matteo/custom done types/resource.module
sandbox/matteo/custom done types/review.module
sandbox/matteo/modules/Drupal CVS/feedback/feedback.module
sandbox/steph/modules/event/event.module
sandbox/steph/modules/xstory/xstory.module
sandbox/walkah/image/45/image.module
sandbox/walkah/image/image.module

I don't recall when this change happened (from 4.4 to 4.5 I think) but it might be worth adding a note to the upgrade guide.

dries’s picture

Title: "Add new comment" no longer shows up in $links? » Rename $main to $teaser where appropriate
Component: poll.module » base system
Category: bug » task

Committed Goba's patch to HEAD. I renamed this issue and marked it active so we can fix the remaining $main/$teaser issues.

rooey’s picture

Both patches, once applied seem to do the trick for the poll-block... The node itself however, still has bad link information when displayed.

I can't see anything obvious - but then it's late and i'm tired ;-)

junyor’s picture

@rooey: What links are you seeing?

coreb’s picture

Version: » 6.x-dev

Moving out of the x.y.z queue into 6.x-dev. I don't know if this was ever fixed or not.

webchick’s picture

Status: Active » Fixed

grepping for $main in HEAD, I only see one reference in hook_footer, which looks to be something completely different.

Marking fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)