Hello... I'm having a problem with anonymous users using fivestar when normal or aggressive caching is enabled. Everything seems to work fine when caching is disabled. I'm using drupal 6.14.

1. An anonymous user views a node that has no votes, and clicks on 5 stars. It says their vote has been saved.
2. If the anonymous user reloads the page, it still says "no votes yet".
3. If I log in as an admin, I can see the one vote, but if I log out and reload the node, it still says "no votes yet".

Did I forget to enable a permission somewhere to allow anonymous users to see other anonymous users' votes?

Thanks!

CommentFileSizeAuthor
#3 fivestar.module-592746-3_D6.patch1.11 KBDarren Oh
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Version: 6.x-1.18 » 6.x-2.x-dev
Category: bug » feature

This actually isn't a bug in that Fivestar has *never* supported showing anonymous votes or expiring the page cache. The "temporary" nature of the vote is intended to provide immediate feedback, but the actual page display won't be updated until the set amount of time passes as configured in the page cache settings (admin/settings/performance).

If Fivestar were actually to expire the page cache, a site with a lot of ratings would constantly be expiring the cache. Some sites (such as usmagazine.com) receive hundreds of comments *a minute*. Even though they're not running Fivestar, it's not hard to imagine a similar situation.

This isn't an unsolvable problem though, we could give anonymous users a cookie to store their ratings on various pieces of content, making it look like their votes stick until the page cache expires and they get a new page anyway. It would also be helpful in showing the user their own rating if you're using a display other than the "Average" display.

So I'll move this to a feature request because this has never formally been requested. However this feature will not be added in the 1.x version (or Drupal 5) since all new functionality is being added to the Drupal 6/7 targeted Fivestar 2.x.

ryansc’s picture

Thank you very much. I totally understand and appreciate you considering this as a feature request.

Darren Oh’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
Category: feature » bug
Status: Active » Needs review
FileSize
1.11 KB

In that case, "Your rating" should not be shown to anonymous users.

Mindy’s picture

This is a major drawback to an otherwise fantastic module. I'm really looking forward to seeing this feature request added somehow. Nifty idea for a workaround, quicksketch!

quicksketch’s picture

I'm no longer actively maintaining Fivestar (ezra-g is now maintainer), but I should note that Flag module has the exact functionality I described in #1, using cookies to maintain a list of all content that uses have flagged as an anonymous user.

hanoii’s picture

subscribe

angelmax’s picture

subscribe

zeagon’s picture

Has anyone found a fix for this yet? or better posted it public soomewhere?

apes132’s picture

subscribe

chuckbar77’s picture

subscribing

geerlingguy’s picture

Subscribe. Also, for those using views to display voting widgets: #592312: Views for Anonymous Users not joined correctly.

ericduran’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev

Moving the 2.x, there won't be any more development in the 1.x branch.

Also I'm curious is this is an actual bug. Can some elaborate why this is file as a bug report?

Thanks.

asb’s picture

Category: bug » feature

I think it's a feature request. But a really important one ;)

Darren Oh’s picture

Category: feature » bug

It was filed as a bug report because, in addition to the missing feature, there is a bug: users are told they have no votes after they have voted. I think it’s important that we disclose this bug to potential users.

ericduran’s picture

Category: bug » feature

This is a feature request. This was done on purpose hence why its not a bug.

Whats the recommended solution? Use cookies for anonymous user to see if they've voted?

That would work fine, but just be aware that we're still not going to be able to tell if the user voted or not if the cookie is no longer present.

Darren Oh’s picture

There are two problems:

1. Anonymous users cannot see their votes = feature request
2. Page shows "Your rating" to anonymous users even though it is not actually available = bug report

I seriously doubt that anyone intended to show anonymous users a "Your rating" widget that tells them they have not voted, no matter how many times they try. It’s more likely that this feature wasn’t tested with caching enabled. But I won’t change the status of this issue.

asb’s picture

In this case, it might make sense to split this issue (#592746) from October 1, 2009, into two distinct threads: One for the feature request (might remain #592746), and one for the bug report (might become a new issue).

There ist also something else which might be connected to the mentioned issues: At least on my sites, anonymous users don't get a Fivestar widget, but a dropdown; logged-in users see the widget (Fivestar widget embedded in a View; maybe related to #592312: Views for Anonymous Users not joined correctly, or maybe a freak incident on my sites).

However, this issue (#592746) has been filed against 6.x-2.x-dev, while most users might be still at 6.x-1.19 tar.gz from 2009-Oct-22; this last stable/recommended release is almost two years old, and the code might have significantly changed from 1.19 to 2.x-dev. I believe it's a real problem if the actual code used in production and the development code is forking too much.

nguyentran’s picture

Hello, in Drupal 7 fix this by go to
Home » Administration » Configuration » Development>> Performance --- Uncheck the "Cache pages for anonymous users "

And if you have problem with "A anon user can votes many times.... " so you can go to link to fix it http://drupal.org/node/997092#comment-3940040

Darren Oh’s picture

We already know this works when caching is turned off. We’re just waiting for someone to review the patch that stops anonymous users from being told they have not voted when caching is on.

Darren Oh’s picture

Title: Anonymous users can't see their votes when caching is enabled. » Anonymous voters are told they have not voted when caching is enabled.
Category: feature » bug
nguyentran’s picture

Version: 6.x-2.x-dev » 7.x-2.0-alpha1

Hello
I see in fivestar.module the position in fivestar_get_votes() function

// If the user is anonymous, we never bother loading their existing votes.
// Not only would it be hit-or-miss, it would break page caching. Safer to always
// show the 'fresh' version to anon users.

I decide to break the page caching, is it good for site. I think if i break the caching, maybe it will work.

Ideas will be appreciated.

Darren Oh’s picture

If you break caching, your site will likely crash whenever it gets a large amount of traffic. Better to stop showing the “no votes yet” message to anonymous users.

nguyentran’s picture

Hi Darren Oh
It's simple to modify the theme not to show the 'no votes yet', but i still don't understand why it crash, i just add soome code after the previous comment to load the new value that the anonymous has voted.
Follow my code

<?php
$criteria += array('uid' => $uid);
$query = db_select('votingapi_vote')->fields('votingapi_vote');
foreach ($criteria as $key => $value) {
    $query->condition($key, $value, is_array($value) ? 'IN' : '=');
}
$user_vote = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
if ($user_vote) {
     $votes['user'] = $user_vote[0];
     $votes['user']['function'] = 'user';
 } 
 else $votes['user'] = array('value' => 0);
?>

That would be great if i can understand more about Drupal

nguyentran’s picture

Hello,

After a long time to find out the solution for this, imho i will clear or disable cache of current page when anonymous visit the page. i have two ways to do this
1 :

     // Disable page caching for anonymous users.
     $GLOBALS['conf']['cache'] = 0;

2:

    // Disable page caching for current page   
    drupal_page_is_cacheable(FALSE);

You can put this code row where loading the field.

Any ideas for my solution, please comment. Thank you so much !

Darren Oh’s picture

You should try it and see what happens when your site receives high traffic. It is not a suitable solution for serious sites.

ken_y’s picture

I concur with Mr. Oh. Breaking the cache will most probably fail with high traffic.

Why not split out the feature request?

Status: Needs review » Needs work

The last submitted patch, fivestar.module-592746-3_D6.patch, failed testing.

MGParisi’s picture

Disable Cache is not the solution. We need to disable cache in a more eloquent way. If turning off cache for anonymous users will lead to a huge increase in performance and will hurt many sites. I will love to use anonymous voting, but not at this cost!

Alan D.’s picture

Love a work around to the anonymous users current vote, spent a bit of time trying to debug this till I found out that this was a feature rather than a bug :/

MGParisi’s picture

Will a bounty put a fire under someones butt?

Darren Oh’s picture

We had a patch here that fixed the bug, but instead of reviewing the patch, people argued that it's not a bug. If someone updates the patch I will be happy to review it, but I'm not wasting my time submitting another patch no one reviews.

MGParisi’s picture

Darren Oh, I could care less if its a "feature" or a "bug". 5 Stars is dead and rating doesn't work either nor does it have the features I want.

It doesn't work and the patch didn't pass the test:( From what the THREAD said I think the patch took away something and didn't fix it so that the entire 5 star would be updated?

If I am wrong, then please re-roll a patch that passes and I will be the first to test it.

PieterDC’s picture

#2297231: Fivestar Not Working for Anonymous Users with Cache Enabled is also about Fivestar issues when page caching is enabled.

It holds a couple of suggestions:

  • Implement hook_votingapi_results() to clear cache of a page whenever someone voted on that page
  • Use Fieldblock and Ajaxblocks to show the Fivestar field in a block and load it with Ajax
  • Use AuthCache to load the Fivestar field with Ajax
dbt102’s picture

Status: Needs work » Closed (outdated)