Drupal Most Recent Poll Block Not Caching
I searched for a bit, but no results and I was wondering if it were my fault that the poll was being cached. But eventually I came upon a Drupal forum post http://drupal.org/node/523676 which gave a patch which is transcribed below:
diff -urp –strip-trailing-cr ../drupal-6.x-dev/modules/poll/poll.install ./modules/poll/poll.install
— ../drupal-6.x-dev/modules/poll/poll.install 2009-01-06 16:46:37.000000000 +0100
+++ ./modules/poll/poll.install 2009-07-18 22:29:37.000000000 +0200
@@ -130,3 +130,21 @@ function poll_schema() {
return $schema;
}+/**
+ * @defgroup updates-6.x-extra Extra poll updates for 6.x
+ * @{
+ */
+
+/**
+ * Fix cache mode for “Most recent poll” block.
+ */
+function poll_update_6000() {
+ $ret = array();
+ $ret[] = update_sql(“UPDATE {blocks} SET cache = 2 WHERE module = ‘poll’ AND delta = ’0′”);
+ return $ret;
+}
+
+/**
+ * @} End of “defgroup updates-6.x-extra”
+ * The next series of updates should start at 7000.
+ */
diff -urp –strip-trailing-cr ../drupal-6.x-dev/modules/poll/poll.module ./modules/poll/poll.module
— ../drupal-6.x-dev/modules/poll/poll.module 2008-12-18 16:46:20.000000000 +0100
+++ ./modules/poll/poll.module 2009-07-18 21:45:53.000000000 +0200
@@ -131,6 +131,7 @@ function poll_block($op = ‘list’, $delta
if (user_access(‘access content’)) {
if ($op == ‘list’) {
$blocks[0]['info'] = t(‘Most recent poll’);
+ $blocks[0]['cache'] = BLOCK_CACHE_PER_USER;
return $blocks;
}
else if ($op == ‘view’) {
@@ -776,6 +777,8 @@ function poll_cancel($form, &$form_state// Subtract from the votes.
db_query(“UPDATE {poll_choices} SET chvotes = chvotes – 1 WHERE nid = %d AND chorder = %d”, $node->nid, $node->vote);
+
+ cache_clear_all();
}/**
If this code looks strange to you you are not alone. I was confused too. I have patched files in linux before, but my webhost, Ixwebhosting, does not have access to ssh or the terminal in general so I was stuck. This was an obvious bug and I could not fix it. All I could find were links to how to convert a patch file to an exe on Windows, but first I have a linux server and also how would I have executed that anyway? So I decided to do it the manual way, open the files and manually edit it. Make sure you back up all original files before editing!
- First open ./modules/poll/poll.install and go to line 130
Findfunction poll_schema() { return $schema; }and add after it
function poll_update_6000() { $ret = array(); $ret[] = update_sql("UPDATE {blocks} SET cache = 2 WHERE module = 'poll' AND delta = '0'"); return $ret; } - Save and exit. Next open ./modules/poll/poll.module and go to line 131
Find:if (user_access('access content')) { if ($op == 'list') { $blocks[0]['info'] = t('Most recent poll'); return $blocks; } else if ($op == 'view') {and replace with:
if (user_access('access content')) { if ($op == 'list') { $blocks[0]['info'] = t('Most recent poll'); $blocks[0]['cache'] = BLOCK_CACHE_PER_USER; return $blocks; } else if ($op == 'view') { - In the same file go to line 777
Find:function poll_cancel($form, &$form_state) {$node = node_load($form['#nid']); global $user; if ($user->uid) {db_query('DELETE FROM {poll_votes} WHERE nid = %d and uid = %d', $node->nid, $user->uid); }else {db_query("DELETE FROM {poll_votes} WHERE nid = %d and hostname = '%s'", $node->nid, ip_address());} // Subtract from the votes.
db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE nid = %d AND chorder = %d", $node->nid, $node->vote);}
and replace with:
function poll_cancel($form, &$form_state // Subtract from the votes. db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE nid = %d AND chorder = %d", $node->nid, $node->vote); cache_clear_all(); } - Save this file and upload. Now the Poll block should work well.









I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you? Plz answer back as I’m looking to construct my own blog and would like to know where u got this from. thanks
There are a few helpful things soon enough in this particular article but I don?? comprehend if I see all of them core to heart. There is some validity however I’ll bring hold belief unless I look at it further. Good article , appreciate it and we wish more! Added to FeedBurner as well
Thanks for sharing Pear’s Fun Facts: Bananarama | Annoying Orange with us keep update bro love your article about Pear’s Fun Facts: Bananarama | Annoying Orange .
My husband and i got more than happy Raymond managed to conclude his homework while using the precious recommendations he grabbed from your web pages. It’s not at all simplistic just to happen to be giving out tips and hints that many other folks have been trying to sell. And we discover we have you to be grateful to because of that. The type of explanations you’ve made, the easy website navigation, the friendships you can make it possible to engender – it is mostly sensational, and it is leading our son and us consider that this concept is fun, and that’s pretty indispensable. Many thanks for all the pieces!
Gift baskets this holidays are something that everyone should be considering during Xmas day and in this short article I’m going to provide you with a handful of main reasons why It really is extremely crucial that you too think about buying gift baskets to your family members.
I’m curious to find out what blog platform you happen to be utilizing? I’m having some minor security problems with my latest site and I’d like to find something more secure. Do you have any recommendations?
Hey good blog!!! Man .. Beautiful .. Incredible .. I am going to bookmark your website and take the feeds also great article thanks Hi. I needed to thank you for that fantastic information you’ve posted on your site. I am going to definitelycome to look it over once again and have subscribedto your Rss. Have a fantastic day.
What youre declaring is completely accurate. I am aware that everyone need to say precisely the same point, but I just believe that you put it within a way that everyone can comprehend. I also enjoy the photos you put in here. They fit so well with what youre wanting to say. Im certain youll reach so many men and women with what youve obtained to say.
I like this web blog very much so much good info.
Magnificent goods from you, man. I have remember your stuff previous to and you’re simply too great. I actually like what you have bought right here, really like what you’re saying and the best way wherein you are saying it. You are making it enjoyable and you continue to take care of to stay it smart. I cant wait to read far more from you. This is actually a tremendous website.