WordPress.org

Ready to get started?Download WordPress

Forums

WP-PostRatings
User ratings lost while post visibility private (9 posts)

  1. jardokraka
    Member
    Posted 5 months ago #

    Case description: you create a post, publish it, users on site have the page loaded in their browsers and start rating the post, then you switch post visibility to hidden/private temporarily because you need some time to make edits.

    Issue: if those who loaded the page while the post was still public rate the post a bit later after the post was made private, their ratings will be lost (the plugin can't update wp_postmeta in the database, I suppose) and won't be reflected in %RATINGS_AVERAGE% / %RATINGS_USERS% for this post.

    BUT their ratings will be listed in the logs correcly, nothing is lost there (I have a section at the bottom of the page which gives a rundown of who rated the post and how) -- so, the plugin updates the wp_ratings table correctly. So, from that moment on there's a discrepancy in ratings as reported at the top of the post (%RATINGS_AVERAGE% / %RATINGS_USERS%) and at the bottom where I query the database and list all users who rated the post and their ratings. That discrepancy is pretty hard to fix unless you manually go to the database and edit the values in wp_postmeta for the post.

    I realize the issue can be avoided by never switching the post visibility to private after publishing it, but perhaps there's a more elegant way of dealing with it, like the plugin could have some sort of built-in protection for this scenario?

    Sorry for the long post, didn't quite know how to describe the problem in a more concise manner.

    Thank you.

  2. Lester Chan
    Member
    Plugin Author

    Posted 5 months ago #

    Is not about post visibility. But because postratings uses postmea to store the data and when you load the post in the edit post screen, the post meta will be loaded with that post and hence whatever has been rated will be over written by the values at the edit post page when you click save changes.

    I am not too sure whether the plugins can do anything to it now since it is meant to allow user to edit the ratings value directly on the edit post page. If the meta name starts with _, it will not have this problem but user will not be able to edit the ratings.

    Another way is to have some sort of sync function to update the postmeta with the correct values from the log. But if user delete the logs then it will cause problem as well. But I kinda like this sync idea.

  3. jardokraka
    Member
    Posted 5 months ago #

    So, it's even more dangerous than I thought then? :) There's a probability some ratings will be lost while I simply edit a published post?

    I am not too sure whether the plugins can do anything to it now since it is meant to allow user to edit the ratings value directly on the edit post page.

    Where is that exactly? I am not seeing any wp-postratings related interface on the edit post screen.

  4. Lester Chan
    Member
    Plugin Author

    Posted 5 months ago #

    PostRating uses custom fields to store the meta for each post (http://codex.wordpress.org/Custom_Fields) so when you load the edit screen, the inital ratings meta are there and when you click save, it will overwrite any new ratings meta that has been created within that time frame.

  5. jardokraka
    Member
    Posted 5 months ago #

    Right, thanks.

    Frankly, I would much rather lose the ability to edit the ratings value directly on the edit post page, but be sure the plugin functions reliably instead. On a busy site where users rate posts actively, losing ratings can be quite an issue. It is for me, as this means that I pretty much need to shut the site down temporarily each time I need to edit a post, or else I risk losing some user ratings :)

    Perhaps there could be an option to use "_"-type (hidden) custom field? But in that case existing ratings will need to be converted somehow.

  6. Lester Chan
    Member
    Plugin Author

    Posted 5 months ago #

    Yea, I want to avoid the route of converting because the plugin has been out for too long, it will require much more work to convert then to add in a sync ratings options in the edit post screen.

  7. jardokraka
    Member
    Posted 5 months ago #

    So, is this on your todo list then? That would be great, thank you so much in advance!

    add in a sync ratings options in the edit post screen.

    As far as I understand, this would mean sync will have to be run manually + one will have to locate posts with lost ratings manualy as well. This would be helpful, yet it wouldn't be a real solution. The plugin must count ratings reliably and protect its data from overwriting to begin with -- not just provide a tool for fixing where it's malfunctioned.

  8. Lester Chan
    Member
    Plugin Author

    Posted 5 months ago #

    Yeap it is on my list but no idea when I will have time to do it.

    I agree on the reliability part, but there is always a trade off. But personally I will want it to be using _ to hide the ratings and don't allow user edit the ratings directly in the post. But as mentioned that is too much work.

    This plugin is way too old, is time for a rewrite eventually or when I have time or when somebody has time to contribute it. Right now I am only fixing immediate criticial issues as that is the only time can spare.

  9. jardokraka
    Member
    Posted 5 months ago #

    Thank you.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.