fivestar_static() unconditionally calls the fivestar_get_votes() function, which in turn runs two SQL queries -- one for the average vote and one for the vote that the currently logged in user gave.

It does this even when the user's vote is not displayed anywhere. This could be optimized by only querying for the logged in user's vote if that information is going to be displayed.

Comments

StatusFileSize
new2.13 KB

This patch fixes the bug, removing the unnecessary SQL query in the case where the user's vote is not displayed

StatusFileSize
new2.55 KB

Please delete this one

StatusFileSize
new2.41 KB

The first patch did not work as advertised. This one should.

Status:Active» Needs work

This patch still isn't quite right because the "dual" display needs the user rating. It looks like this code could be shortened up a bit, since the *only* situation where the user's rating is not needed is if the the display is "average" only.

Version:6.x-1.13» 6.x-1.15
Status:Needs work» Needs review
StatusFileSize
new1.72 KB

Rerolled the patch against 1.15 and incorporated quicksketch's suggestion in comment #4

Category:bug» task
Status:Needs review» Needs work
StatusFileSize
new1.63 KB

Heh, well there's *still* one use-case that this breaks. The user's vote is still necessary if using any of the display texts except "none" and "average". I rerolled and applied the attached patch, which should satisfy the performance improvement you were hoping for.

Status:Needs work» Fixed
StatusFileSize
new1.65 KB

Updated patch for the 2.x version. Both versions committed.

Status:Fixed» Closed (fixed)

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