Drupal 5 Fivestar Not Compatible with jQuery 1.2+

asb - May 10, 2009 - 12:14
Project:Fivestar
Version:5.x-1.15
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

Hi,

after upgrading to version 1.15, the Fivestar widget does not accept votes anymore. It was working before, and I haven't changed the configuration (excpect running update.php after the update).

Any ideas?

Thanks & greetings, -asb

#1

quicksketch - May 10, 2009 - 19:47
Status:active» postponed (maintainer needs more info)

You will need to be more specific. It doesn't accept votes? You mean the stars aren't clickable, or the rating doesn't save after clicking? Does it affect anonymous or logged in users?

#2

quicksketch - May 10, 2009 - 19:49

I think there might have been a bug in earlier versions of Fivestar that allowed all users to rate content, make sure that anonymous users have "rate content" permission from the admin/user/access page.

#3

asb - May 11, 2009 - 23:20

> You will need to be more specific. It doesn't accept votes? You mean the stars aren't clickable, or the rating doesn't save after clicking?
> Does it affect anonymous or logged in users?

Sorry, I don't know what is happening since I know of no logfile or watchdog entries about failed attempts to vote on a node (at least /admin/logs/watchdog has no "Fifestar" category in my installations). A logged-in user can hover over the stars, they highlight if he/she clicks on it, and that's it: the stars don't change when the mouse moves away. Below the stars, it says: "Your rating: None", and: "No votes yet". The same happens if user #1 tries to vote (to my understanding, user #1 should have all available permissions).

However, if I grant anonymous users the permission to vote through /admin/user/access (what I don't in this case by default), the vote of an anonymous user is being saved. Actions of user #1 are still not accepted, even if every role has "rate content" permissions. The same goes for an logged-in user of whatever role. So basically after upgrading 5.x-1.14 to 5.x-1.15, only anonymous users seem to be able to vote but nobody else; if the site does not accept votes of anonymous users, simply nobody can vote anymore.

Greetings, -asb

#4

quicksketch - May 12, 2009 - 01:20

A logged-in user can hover over the stars, they highlight if he/she clicks on it, and that's it: the stars don't change when the mouse moves away.

Well the stars *should* stay if the user clicks on them, but the text below should be updated to reflect the vote being saved. It sounds like you might be having a JavaScript error along the way that prevents Fivestar from making the AJAX request. Can you see any errors in Firebug (for Firefox) or other errors? What browser are you testing this in? Whatever the problem, it doesn't seem to occur on a clean install of Drupal and Fivestar on my local machine.

#5

asb - May 12, 2009 - 15:23

I'm mostly working with Opera 9.x on Windows XP and Ubuntu; in "Opera Dragonfly", the error console shows no errors when trying to vote, at least none I would see (I'm not used to those tools; I'm willing to help out, but need instructions).

In Firefox 3.x, the error console shows no Javascript errors when attempting to vote. However, in Firefox/Ubuntu, also anonymous users can't vote: E.g. when clicking on star 5/10, the stars 1-5 change their color permanently; below the stars the text changes to "Saving your vote...", also permanently. "Average: 6 (1 vote)" remains, the vote is not being registered.

When clicking in the star, HttpFox registers at "POST Data" an acces to an url like "http://www.mysite.com/fivestar/vote/node/12855/vote/50?token=a5ed6dae85d607954fe4b9e09de9dc4b". The "Content" tab of HttpFox says:

<xml>
<error>Invalid token</error>
</xml>

Also the URL/path appears strange; I'm not sure if the "/fivestar/vote/node/12855/" part is valid ("12855" is the NID of the node I tried to vote on, "50" is the submitted rating, the widget is configured for "Number of stars = 10"). Other configuration:

* Star Labels: @star/@count (on all 10 labels)
* Star display style: Both user and average vote
* Text display style: Both user and average vote
* Show widget title: Yes
* Allow users to undo their votes: Yes
* Enable confirmations to inform a vote was saved or deleted: Yes
* Teaser display:
* Full node display: Clickable widget below node body
* Fivestar comment settings: (deactivated)

Regarding Javascript: I'm running jQuery Update which installs jQuery version 1.2.6. And yes, there might be an issue with Javascript: I'm using a CCK date field which is configured as "Text Field with jquery pop-up calendar"; that pop-up calender never appears. I just re-checked the configuration of the jQuery Update module which seems to be correct. Sorry that I can't provide more helpful information :-(

Greetings, -asb

#6

quicksketch - May 12, 2009 - 15:56

Hm, so it sounds like the token isn't being accepted by the server. The query looks fine.

fivestar/vote/node/12855/vote/50
fivestar/vote/[content-type]/[content-id]/[voting-tag]/[rating]

Then the token=a5ed6dae85d607954fe4b9e09de9dc4b is the token that validates the request is valid. I'm still not sure why it's not working though. You should try to start with a clean Drupal install and see if you can reproduce the problem from the fresh install.

#7

asb - May 12, 2009 - 16:34

Just tried it on my testing site where "Fivestar" wasn't installed before: Downloaded the module, activated it, enabled it for one custom node type; the behaviour is exactly the same. Stripped all Javascript intense modules (like "Admin Menu") one by one, until only jQuery Update was left. Disabled it, "Fivestar" started working again; re-enabled it, "Fivestar" stopped working again.

As it seems, "Fivestar" is simply incompatible with jQuery update. Can you replicate this?

Greetings, -asb

#8

quicksketch - May 12, 2009 - 20:28
Title:Fivestar does not accept votes» Drupal 5 Fivestar Not Compatible with jQuery 1.2+
Priority:critical» normal
Status:postponed (maintainer needs more info)» active

Okay, well I think we've found the source of the problem. It's true that Fivestar is not compatible with the 2.0 version of jQuery update because the syntax for jQuery changed between version jQuery 1.1 and jQuery 1.2. I'd suggest using the 5.x-1.0 version of the jQuery Update module, which will update your site to jQuery 1.1.2.

It's possible for Fivestar to work with jQuery 1.2 and higher (since the Drupal 6 version works with 1.1 and higher), but it's just difficult to support all the possible versions. We can probably fix this problem by avoiding the incompatible selectors, most notably currentValue = $("input[@name=vote_average]", $obj).val(); on line 47 of fivestar.js and some similar selectors in fivestar-admin.js.

Ultimately, your site really just needs to be updated to Drupal 6, where modules have rewritten their JavaScript to support 1.2 and higher. Like you've noted, Date's calendar doesn't work either. Neither will most any other module that provides JavaScript in Drupal 5. The syntax changes between the 1.0.4 (the version Drupal 5 shipped with) and 1.2.6 (the version in jQuery Update 2.0) are too drastic for most modules to accommodate for.

#9

asb - May 12, 2009 - 23:41

> Ultimately, your site really just needs to be updated to Drupal 6, where modules have rewritten their JavaScript to support 1.2 and higher.

You're most definitely right with that. Let's keep hoping this will become possible at a very happy day.

Greetings, -asb

#10

iex - May 27, 2009 - 13:14

I have the similar problem, but Fivestar just stopped working for me for some reason. It displays "Saving vote..." all the time and is not saving anything.
I tinstalled the lates version of Fivestar 1.15 for my Drupal 5.2, it didn't helped. Then i enabled the jQuery update module and it updated the jQuery to 1.1.2, but still no effect.
There are reasons i can't update Drupal to 6, are there any solutions at the moment?

#11

iex - May 28, 2009 - 07:43

Not actual anymore.
The problem was i disabled the Devel module needed to 'fivestar_userpoint' module to work properly :) It just couldn't update the userpoints.

#12

quicksketch - July 1, 2009 - 02:22
Status:active» won't fix

The Drupal 5 version will never be updated to work with newer versions of jQuery beyond 1.1.x.

#13

lestu - November 3, 2009 - 11:12

I have the exact same issue as asb described in #5, but on drupal 6.13.

tried various Fivestar versions up to 6.x-2.x-dev.
just installed jQuery Update 6.x-1.1.

gave permissions to all roles, even anonymous. but only the admin user can give a vote. for all other users/roles, the text hangs on "Saving your vote...", no vote is saved, and the xml response is "Invalid token".

Can anyone help please ?

#14

lestu - November 3, 2009 - 11:57

Solved!

For me, the culprit was the Firefox plugin "Cookie Pie", which allows you to have multiple separate sessions on the tabs in your browser window. It's very useful for testing webapps...
BUT! If you make on tab a separate session, the outgoing AJAX requests will still be made through the main session, which in my case, was the admin.

Hope this helps somebody :)

 
 

Drupal is a registered trademark of Dries Buytaert.