Nick
01-16-2010, 02:46 PM
I noticed a bug in the upgrade script from 1.0 to 1.0.1, and it hasn't been fixed yet.
The problem is that when the vote_rating column in the database postvotes table was changed from varchar to smallint, it reset all the existing votes to the new default of "0". That's a big problem, especially if you imported a Pligg/SWCMS site into Hotaru and upgraded from 1.0 to 1.0.1, or 1.0 to 1.0.2. If you started with 1.0.1 and upgraded to 1.0.2, you are not affected.
Here's the offending code. The problem is clearly with the ALTER TABLE query, but I don't know how to change it so that it doesn't reset all the values to the default:
// Change "positive" to 10
$sql = "UPDATE " . TABLE_POSTVOTES . " SET vote_rating = %d WHERE vote_rating = %s";
$h->db->query($h->db->prepare($sql, 10, 'positive'));
// Change "negative" to -10
$sql = "UPDATE " . TABLE_POSTVOTES . " SET vote_rating = %d WHERE vote_rating = %s";
$h->db->query($h->db->prepare($sql, -10, 'negative'));
// Change "alert" to -999
$sql = "UPDATE " . TABLE_POSTVOTES . " SET vote_rating = %d WHERE vote_rating = %s";
$h->db->query($h->db->prepare($sql, -999, 'alert'));
// Alter the PostVotes table so the vote rating is an INT
$sql = "ALTER TABLE " . TABLE_POSTVOTES . " CHANGE vote_rating vote_rating smallint(11) NOT NULL DEFAULT %d";
$h->db->query($h->db->prepare($sql, 0));If all your votes have a rating of zero (check your postvotes table) then a Who Voted or Points plugin won't be able to check votes, and anything you voted for in the past won't be recognized. Unfortunately, it's not possible to reverse that mistake because all positive, negative and flagged posts will all have the same value and we can't tell them apart.
That's my fault, I should have noticed earlier. I'm sorry if you have to run the Pligg Importer again to fix your data. I'll be more careful in future. :(
The problem is that when the vote_rating column in the database postvotes table was changed from varchar to smallint, it reset all the existing votes to the new default of "0". That's a big problem, especially if you imported a Pligg/SWCMS site into Hotaru and upgraded from 1.0 to 1.0.1, or 1.0 to 1.0.2. If you started with 1.0.1 and upgraded to 1.0.2, you are not affected.
Here's the offending code. The problem is clearly with the ALTER TABLE query, but I don't know how to change it so that it doesn't reset all the values to the default:
// Change "positive" to 10
$sql = "UPDATE " . TABLE_POSTVOTES . " SET vote_rating = %d WHERE vote_rating = %s";
$h->db->query($h->db->prepare($sql, 10, 'positive'));
// Change "negative" to -10
$sql = "UPDATE " . TABLE_POSTVOTES . " SET vote_rating = %d WHERE vote_rating = %s";
$h->db->query($h->db->prepare($sql, -10, 'negative'));
// Change "alert" to -999
$sql = "UPDATE " . TABLE_POSTVOTES . " SET vote_rating = %d WHERE vote_rating = %s";
$h->db->query($h->db->prepare($sql, -999, 'alert'));
// Alter the PostVotes table so the vote rating is an INT
$sql = "ALTER TABLE " . TABLE_POSTVOTES . " CHANGE vote_rating vote_rating smallint(11) NOT NULL DEFAULT %d";
$h->db->query($h->db->prepare($sql, 0));If all your votes have a rating of zero (check your postvotes table) then a Who Voted or Points plugin won't be able to check votes, and anything you voted for in the past won't be recognized. Unfortunately, it's not possible to reverse that mistake because all positive, negative and flagged posts will all have the same value and we can't tell them apart.
That's my fault, I should have noticed earlier. I'm sorry if you have to run the Pligg Importer again to fix your data. I'll be more careful in future. :(