Multisite WP-Postratings bug in cookie management

Multisite WP-Postratings plugin bug in cookie management

WP-Postratings plugin for WordPress has a bug in cookie management that inhibits to vote posts with same ID in a WordPress Multisite installation. Here, how to fix it.

 

When a user votes a post, WP-Postratings sets a cookie, which contains the post ID with the PHP function bool setcookie($key, $value). Then, when a user opens a post through the browser, WP-Postratings plugin checks if the user has the cookie. If the cookie is present, the plugin reads the post ID inside the cookie and it checks if the post ID read in the cookie is equal to the post ID of the post opened by the user. If they are equal it means that the user has already voted the post thus the plugin inhibits the possibility to vote again.

The problem is that in multisite installation the post ID of different blogs are NOT unique. Thus, user “X” in blog “A” can vote the post with ID:111 but user “X” can’t vote another post with ID:111 in blog “B”, “C” etc..

To fix the bug is sufficient to modify the file wp-postratings.php, which is in the plugin folder.

At row 300 the function check_rated_cookie must be changed from:

to:

At row 640 the if section must be changed as it follows:

 

Done. Now your plugin should work correctly.

 

See you soon.


Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *