Wakaba - broken repair_database() (8)

1 Name: Fashnek : 2007-04-25 17:06 ID:1YL+896F [Del]

I noticed this bug a very long time ago (with a much older version), but I never did figure out what it was (I've never used Perl). While hacking in some new features, I finally found it. It's still there, so I thought I should bring it up.

Basically the bug makes repair_database() useless because it does not loop through all the threads (to reset 'lasthit') like it should. The problem is on line 1730 of the most recent version of wakaba.pl.

while($row=$sth->fetchrow_hashref()) { push(@threads,$row); }

foreach $thread (@threads)
{
my $upd=$dbh->prepare("UPDATE ".SQL_TABLE." SET lasthit=? WHERE parent=?;") or make_error(S_SQLFAIL);
$upd->execute($$row{lasthit},$$row{num}) or make_error(S_SQLFAIL." ".$dbh->errstr());
}

The last statement should use $thread, not $row.

I wish I had found this long ago! It would have made the odd behavior from some of my additions go away completely.

2 Name: Anonymous : 2007-04-25 17:40 ID:Heaven [Del]

waiting for comfirmation from WaHa before I make this change on my wakaba boards.

3 Name: Fashnek : 2007-04-25 22:14 ID:1YL+896F [Del]

Do you need confirmation? Just look at what that function (subroutine?) does. :P

It takes every parent post and makes sure all the replies have the same "lasthit" value. This is what makes the posts sort correctly and display in the right order. Otherwise you can (and sometimes do) wind up with replies above the parent, making them look like they're replies in a different thread. Nasty business.

4 Name: Anonymous : 2007-04-26 00:26 ID:Heaven [Del]

>>3
I am a lazy admin that has coders that do this kind of stuff for me. :( I'm not savvy enough to understand all this bibble babble.

5 Name: !WAHa.06x36 : 2007-04-26 05:22 ID:sD3UcZIu [Del]

Oops, you're entirely right. Well, as repair_threads has effectively been a no-op for years anyway, it doesn't really matter unless you're doing wacky things with the database. It was only necessary at some time in the distant past after a database change.

Funny that it caused no noticeable problems then, though.

6 Post deleted by moderator.

7 Name: Anonymous : 2007-05-05 05:17 ID:sj6Gquze [Del]

WAHa, could you upload a bugfixed version of Wakaba to your site (no version number upgrade necessary, I think)?

8 Name: !WAHa.06x36 : 2007-05-05 07:13 ID:Heaven [Del]

>>7

As I said, this doesn't affect anything in normal usage, no fix is necessary for 99% of users. If you're doing something that would make this affect you, you know how to fix it yourself.

It'll be included in the next releases, whenever I geet around to putting that together.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: