I've just upgraded my drupal website from 5.8 to 5.15. I noticed after running the site again that the poll result are not displayed in the node pages "node/111" but they are in the sidebar block !! ...
how could this happen.
I tried replacing the poll.module with the old one but nothing changed.

<div class="node node-poll" id="node-5703">
      <div class="info"> submitted by <a title="view profile" href="/user/3">Dr.Abody</a> on Wed, 11-2-2009</div>
    <div class="content"/>
    <div class="links"><ul class="links inline"><li class="first last statistics_counter"><span class="statistics_counter">552 reads</span></li>
</ul></div>
  </div>

There's nothing in the content div element but the links !!!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drumm’s picture

Status: Active » Postponed (maintainer needs more info)

Can not reproduce with Garland. What theme are you using?

AmrMostafa’s picture

Status: Needs review » Active
FileSize
784 bytes
51.78 KB

This happens because of #154859: Document that cached entity objects are not necessarily cloned any more and I can reproduce it with HEAD, with Garland.

See attached screenshot.

To reproduce:

  1. You should have PHP 5. (Well for HEAD that's a must, but I'm saying for D5/6).
  2. Enable the poll block.
  3. Create a new Poll.
  4. Visit that Poll node or visit /node with that poll promoted to front page.
  5. You should not see the poll node contents, whether it's the vote form or the results.

A patch for HEAD is attached. I've to say, I hate that patch. I believe the right fix is to get this fixed: #154859: Document that cached entity objects are not necessarily cloned any more

AmrMostafa’s picture

Title: Poll results are not displayed in the node page. » Poll node is not displayed when poll block is displayed as well
Version: 5.15 » 7.x-dev
Status: Postponed (maintainer needs more info) » Needs review
pp’s picture

Status: Active » Needs review
Issue tags: +Needs tests

I reviewed the patch. It's good, and kill the bug.
I suggest write test for this bug.

stella’s picture

Title: Poll node is not displayed when poll block is displayed as well » Poll module fixes (due to recent api changes) and tests
FileSize
1022 bytes

I've merged in #453554: Poll block is always rendered as the node one line patch fix into this one since they appear to be inter-dependent. It removes an obsolete parameter which was causing the block to be rendered with the page layout.

There were too many tests missing, so I opened a separate ticket for them in #474308: poll module - new simple tests.

Cheers,
Stella

stella’s picture

Title: Poll module fixes (due to recent api changes) and tests » Poll node is not displayed when poll block is displayed as well
pp’s picture

What the hell. I couldn't review the patch. My computer (with which I reviewed it earlier) is dead. This computer has "PHP Version 5.2.4-2ubuntu5.6" but bug isn't presents. I don't understand.

I saw the poll.module and node.module (node_load) in the current code and I didn't saw changes. I saw the CVS messages. I found one relevant patch #474302: Poll module fixes - due to recent api changes It has not any relevant changes.

Anybody reproduce this bug with the new CVS Drupal release?

pp

stella’s picture

I can still reproduce a problem with the latest HEAD, but it's a bit different - I get content in both areas, it's just incorrect content.

Without the changes in the patch, the block gets the page view, e.g. it contains the 'add new comment' link.

If you only include the poll_view() line api fix, then there's still an issue. The block still contains the 'add new comment' link, and the node doesn't contain the 'cancel your vote' button.

stella’s picture

FileSize
3.97 KB

Patch rewrite.

The poll module was using poll_view() for generating the node content and the block content, which meant supplying an extra param to poll_view() to identify it was using it for a block, rather than a node page. It also called poll_view() directly. After a discussion on IRC with catch, we thought it might be better to split this function, so this patch is a first draft of this. The patch also moves the cloning into poll_block_latest_poll_view().

Cheers,
Stella

pp’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
29.57 KB

I see. If I click "Add new comment" link the block content will bee empty.

The patch resolve this problem.

catch’s picture

Patch looks good to me too. Poll adding an extra param to it's implementation of hook_view() then calling it directly, when it's one of about three implementations of hook_view() in the entire CVS repository doesn't set a good example IMO. Two distinct functions is better, and there's no serious code duplication by splitting them out.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
+  // Necessary for shared objects: http://drupal.org/node/154859
+  // Prevents block output from being the same as the node output.
+  $node = clone $node;
+  unset($node->content);

Could we flesh that comment out a bit? I'd rather drop the reference to the URL and instead explain inline why we do this.

Other than that this looks fine. The duplicated code sucks a bit, but I agree that the fewer weirdo conventions we introduce (especially in Poll module :P), the better off we are.

stella’s picture

Status: Needs work » Needs review
FileSize
4.17 KB
catch’s picture

Status: Needs review » Reviewed & tested by the community

That comment is a lot better.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks!

Now let's get those tests in there. :D

Status: Fixed » Closed (fixed)

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