Gossamer Forum
Home : Products : Gossamer Links : Discussions :

GLinks 3 Upgrade Issues : Corrupted Categories

Quote Reply
GLinks 3 Upgrade Issues : Corrupted Categories
I attempted to upgrade a Links SQL 2.x database with approx. 700,000 links and 90,000 categories to GLinks 3.

During the "Adding Category tree..." section, I got this error:

Code:
Adding Category tree...
--------------------------------------------------------------------------------
Error
An error occured:
No parent category found for Gaming Resources/Card Gaming Resources/Combining! Your Category table is corrupted. at
/var/www/cgi-bin/iwd/admin/Links/Upgrade.pm line 157.


The parent category was there but it had an inconsistent Full_Name with the child catgory. I fixed this with MySQLMan and then encountered some others which I fixed as well. The upgrade then completed without errors. Only thing I noticed was that the def files were not updated properly to the new structure. Maybe it had something to do with reinstalling again after each error. I'll patch this up manually against another GLInks3 installation.

Also, the build repair on Links SQL 2.x did not pick up these category structure errors prior to the upgrade.

A script that checks and lists these corrupted categories before the actual upgrade would have been useful. Otherwise,
everything seems to be ok with the upgrade.

Hope this was useful.

Regards,
Peter Puglisi
www.ausfreedom.com
Ultimate Freedom is our game.
Quote Reply
Re: [rocco] GLinks 3 Upgrade Issues : Corrupted Categories In reply to
I had this issue also, and reported it. I spent many hours fixing broken categories that have apparently been broken for a couple of years. Would have been nice if the upgrade from 2.1 to 2.2 or 2.2.1 would have caught the problem.
Quote Reply
Re: [rocco] GLinks 3 Upgrade Issues : Corrupted Categories In reply to
Hi,
I've written a script to report corrupted categories names. It will report any mismatches between a category's parent name and the category's full name. You can then fix them with MySQLMan by hand as there really shouldn't be many and this is probably safer.

You'll need to modify the path to your admin.

Hope others find it useful.

Code:

#!/usr/bin/perl
use strict;
use lib '/var/www/cgi-bin/admin';
use GT::Base;
use Links qw/$CFG $IN $DB/;
Links::init("/var/www/cgi-bin/admin");
my $table = $DB->table('Category');
my $totalcats = $table->count;
my $sth = $table->select;
while (my $category = $sth->fetchrow_hashref) {
my @catparts = split /\//, $category->{Full_Name};
my $nparts = scalar(@catparts);
my $endpart = $catparts[-1];
# get the parent part
my $parpart = '';
for ( my $q=0; $q<($nparts - 1); $q++ ) {
$parpart .= $catparts[$q] .'/';
}
chop $parpart;
my $thiscatid = $category->{ID};
my $thisparid = $category->{FatherID};
my $thiscatname = $category->{Name};
# get the parent full name
my $parfullname = $table->select( ['Full_Name'], { ID => $thisparid } )->fetchrow;
# check for mismatch between category's name and full name - should rarely happen but worth checking
if ( $endpart != $thiscatname ) {
print_warning ( 1, $thiscatid, $category->{Full_Name}, $thiscatname );
};
# check for mismatch between category's parent name and category's full name - this is the one we really want to trap
if ( $parpart != $parfullname ) {
print_warning ( 2, $thiscatid, $parfullname, $category->{Full_Name} );
};
}
print "\n\nCategory checks complete. $totalcats checked.";

sub print_warning
{
my ( $type,
$catid,
$name1,
$name2 ) = @_;

if ( $type == 1 ) {
print "\nWarning: [Cat. ID $catid] - Mismatch between full category name $name1 and category name $name2.";
} elsif ( $type == 2 ) {
print "\nWarning: [Cat. ID $catid] - Mismatch between parent category full name $name1 and category full name $name2.";
} else {
print "\nWarning: Type $type.";
}
}

Regards,
Peter Puglisi
www.ausfreedom.com
Ultimate Freedom is our game.
Quote Reply
Re: [rocco] GLinks 3 Upgrade Issues : Corrupted Categories In reply to
Hi,

Yes, apparantly several of us have reported that error.

One way that does seem to fix it, is if you import your database, and _before_ doing anything to it, run the category tree option. If that is built first, it seems to fix up problems.

To remove an exisiting category tree, is a process, and I've already raised my hand for an automed "remove" and brute-force repair of /full/names and Father's

As pointed out, the "broken" names have often been in the database for years, and just gave some funky output and random errors, but didn't totally break the system.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [rocco] GLinks 3 Upgrade Issues : Corrupted Categories In reply to
Andy wrote this awhile ago:

http://ultranerds.com/cgi-bin/details/78.html

It repairs the Full Name field. I don't know if that will fix up the issues or not.

Once the category tree table is corrupted, i don't know what will happen, since I have not figured out exactly what that does, but repairing the Full Names is probably easier this way than by hand.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] GLinks 3 Upgrade Issues : Corrupted Categories In reply to
This is a different issue. rocco's code checks for situations where inconsistencies in the database causes the addition of the Category tree to fail.

Adrian
Quote Reply
Re: [rocco] GLinks 3 Upgrade Issues : Corrupted Categories In reply to
Sorry, the string compare's should be using "ne". Here's the affected code:

Code:

# check for mismatch between category's name and full name - should rarely happen but worth checking
if ( $endpart ne $thiscatname ) {
print_warning ( 1, $thiscatid, $category->{Full_Name}, $thiscatname );
};
# check for mismatch between category's parent name and category's full name - this is the one we really want to trap
if ( $parpart ne $parfullname ) {
print_warning ( 2, $thiscatid, $parfullname, $category->{Full_Name} );
};

Regards,
Peter Puglisi
www.ausfreedom.com
Ultimate Freedom is our game.