Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Bought Links with a bug, so help is needed

Quote Reply
Bought Links with a bug, so help is needed
Hi,

I just bought Links SQL and it has a frustrating bug. Everything is setup correctly but I am getting the dreaded "Unable to modify category *The record you are attempting to modify has changed since you last accessed it. "error despite the fact that no, the record hasn't changed and the timestamps are correct.

It's rendered my use of Links SQL to be futile. I can't edit categories and links.

Andy has been very helpful but I think this one will stump him too. The timestamps are correctly set, the installation was correct. But the bug is still preventing me from using the newly purchased script.

So I am left with little option but to:
  1. not use a script I just spent $450 on.
  2. Workaround the bug by disabling the feature (this is not a satisfactory solution, I do not like breaking a script to fix a bug).
  3. ask anyone out there if they know how to fix this


I have seen others have this problem before, the solutions for them won't work for me (they were using problematic plug-ins while mine is a fresh install).

So please give em a hand. It's a tough pill to swallow and I don't have $450 to waste on non-functional code. Any ideas?

Thanks in advance.

cdkrg

Able2Know :: Ajooja Directory

Last edited by:

Andy: Oct 4, 2003, 3:22 AM
Quote Reply
Re: [cdkrg] Bought Links with a bug, so help is needed In reply to
Well, when LinksSQL works it's a dream. When it doesn't (and this is altogether too drequent) it's a nightmare. Andy resolved the problem by modifying Table.pm

I had specifically asked not to hack up the code to solve this problem because I knew it would not be a acceptable fix. His modification was sucessful in getting rid of the first error but in returm it has given me a new one that is worse.

With the default LinksSQL code I get this error when validatng/editing:

The record you are attempting to modify has changed since you last accessed it.

This is with nobody accessing the record of course.
Andy's workaround worked but it means that I can't validate anything. When trying to validate I get this error:

Error: Unable to validate link: 854. Reason: Failed to execute query: 'SELECT COUNT(*) FROM lsql_Links WHERE ( Timestmp => ? AND ID = ? ) ' Reason: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '=> '20031010145026' AND ID = '854' )' at line 1

I am attaching the modified Tables.pm file that Andy altered. I would really appreciate some help. I bought LinksSQL and on a fresh install (actually almost 20 installs) it would not work. Andy could not understand why. It continues not to work.

GT claims my right to the 30 days of free tech support expired before I had even heard of LinksSQL, I understand their reasoning behind this (I bought from a reseller, which was a mistake as it voided all my support) but this is very frustrating. I have a script I paid for (when I had long used perfectly dunctional GPL scripts) and now can't use it.

Can anyone lend me a hand? LinksSQL is a dream when it's working. I'd love to see it actually work.

cdkrg

Able2Know :: Ajooja Directory
Quote Reply
Re: [cdkrg] Bought Links with a bug, so help is needed In reply to
In case it helps i did notice that one change to the Tables.pm file Andy made was to add the following to the beginning:

use GT::SQL;


Edit:

I found the main difference in Andy's version and the original:

Original:




# -------------------------------------------------------------------
# Won't modify a record if the passed in timestamp is older then
# what's in the database.
#
my ($self, $keys, $set) = @_;

# first check to see if we even need to look up the orig timestamp.
my $auto = $self->time_check;
return 1 unless ($auto);
my $found = 0;
foreach (keys %$auto) {
exists $set->{$_} and ($found = 1); # should only be one timestamp.
}
return 1 unless ($found);

# if we got here, then we do a search on the record and compare timestamp.
my $pk = $self->{schema}->{pk};
my $cond = GT::SQL::Condition->new;
my @res;
foreach my $key (@$pk) {
$cond->add ($key, "=", $keys->{$key});
}
foreach my $tmstmp (keys %$auto) {
push @res, $tmstmp;
$cond->add ($tmstmp, ">", $set->{$tmstmp});
delete $set->{$tmstmp};
}
my $sth = $self->select ($cond, \@res) or return;
if ($sth->fetchrow_arrayref) {
return $self->error ('ALREADYCHANGED', 'WARN');
}
else {
return 1;
}
}
END_OF_SUB




Andy's




# -------------------------------------------------------------------
# Won't modify a record if the passed in timestamp is older then
# what's in the database.
#
my ($self, $keys, $set) = @_;

my $IN = new GT::CGI;

#if ($IN->param('do') =~ /modify/) { return 0; }

my $ID = $keys->{ID};
my $Timestmp = $set->{Timestmp};
my $DB = new GT::SQL '/home/a2kname/public_html/cgi-bin/links/admin/defs';

my $cond = GT::SQL::Condition->new(
'Timestmp', '=>' ,$Timestmp,
'ID','=',$ID
) or return $GT::SQL::error;
#$cond->bool('AND');
my $count = $DB->table('Links')->count($cond);

if (!$count) {
return 0;
} else {
return $self->error ("ALREADYCHANGED and ($count,$Timestmp,$ID)", 'WARN');
}

# first check to see if we even need to look up the orig timestamp.
# my $auto = $self->time_check;
# return 1 unless ($auto);
# my $found = 0;
# foreach (keys %$auto) {
# exists $set->{$_} and ($found = 1); # should only be one timestamp.
# }
# return 1 unless ($found);

# if we got here, then we do a search on the record and compare timestamp.
# my $pk = $self->{schema}->{pk};
# my $cond = GT::SQL::Condition->new;
# my @res;
# foreach my $key (@$pk) {
# $cond->add ($key, "=", $keys->{$key});
# }
# foreach my $tmstmp (keys %$auto) {
# push @res, $tmstmp;
# $cond->add ($tmstmp, ">", $set->{$tmstmp});
# delete $set->{$tmstmp};
# }
# my $sth = $self->select ($cond, \@res) or return;
# if ($sth->fetchrow_arrayref) {
# return $self->error ('ALREADYCHANGED', 'WARN');
# }
# else {
# return 1;
# }
}
END_OF_SUB

cdkrg

Able2Know :: Ajooja Directory

Last edited by:

cdkrg: Oct 10, 2003, 6:24 PM
Quote Reply
Re: [cdkrg] Bought Links with a bug, so help is needed In reply to
I changed andy's code from

'Timestmp', '=>' ,$Timestmp,


to

'Timestmp', '=' ,$Timestmp,


And now the validations work. But I'd still like to get this resolved once in for all.

cdkrg

Able2Know :: Ajooja Directory
Quote Reply
Re: [cdkrg] Bought Links with a bug, so help is needed In reply to
Ah, sorry about that... GT::SQL::Condition works with => , but normal GT::SQL::Table->select() uses => .... serves me right for working late when doing it Frown

Is it all working ok for you now?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Bought Links with a bug, so help is needed In reply to
I still can't email you so I'm replying here.

It's working, but I have no idea what I did there Cool, I just tested the SQL on the database and found that => did not return a value but that = did. Was I right to make that change? I was feeling all kinds of bold. The first time I ever looked at PERL was since I bought LinksSQL and I have no idea what I am doing (but am not gonna let that stop me Tongue ).

I'd really rather have the original code work, but as long as this does not cause other bugs I can live with it. I just worry about LinksSQL upgrades and keeping this working.

cdkrg

Able2Know :: Ajooja Directory
Quote Reply
Re: [cdkrg] Bought Links with a bug, so help is needed In reply to
Yeah, its a bit of a weird one.

Just so you know, this is why it wasn't working;

=> in GT::SQL::Condition is invalid syntax, as it would give WHERE Timestmp => $Timestmp, while it should be WHERE Timestmp = $Timestmp.

Doing something like this;

my $table = $DB->table('Links')->select( { Timestmp => $Timestmp } ) would equal to WHERE Timestmp = $Timestmp, which is the correct syntax.

Just so you know what the error was related to Tongue

>>>I'd really rather have the original code work, but as long as this does not cause other bugs I can live with it. I just worry about LinksSQL upgrades and keeping this working. <<<

As long as you make a note that this sub has changed (_chk_timestmp I think it is), then you can just apply that fix to any upgrades you do, and there shouldn't be any problems.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!