Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#7 | fivestar_get_votes_efficiency2.patch | 1.65 KB | quicksketch |
#6 | fivestar_get_votes_efficiency.patch | 1.63 KB | quicksketch |
#5 | 410154.patch | 1.72 KB | Wesley Tanaka |
#2 | 410154.patch | 2.55 KB | Wesley Tanaka |
#3 | 410154.patch | 2.41 KB | Wesley Tanaka |
Comments
Comment #1
Wesley Tanaka CreditAttribution: Wesley Tanaka commentedThis patch fixes the bug, removing the unnecessary SQL query in the case where the user's vote is not displayed
Comment #2
Wesley Tanaka CreditAttribution: Wesley Tanaka commentedPlease delete this one
Comment #3
Wesley Tanaka CreditAttribution: Wesley Tanaka commentedThe first patch did not work as advertised. This one should.
Comment #4
quicksketchThis 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.
Comment #5
Wesley Tanaka CreditAttribution: Wesley Tanaka commentedRerolled the patch against 1.15 and incorporated quicksketch's suggestion in comment #4
Comment #6
quicksketchHeh, 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.
Comment #7
quicksketchUpdated patch for the 2.x version. Both versions committed.