Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

problem deleting Links using plugin

Quote Reply
problem deleting Links using plugin
Hi,

I'm having a problem deleting Links from the Links_Links table. The aim of this plugin is to delete Links that are older than 2 days. The plugin would be run via a cron job at a specific time. The code is as follows:

# ==================================================================
# Plugins::remove_links - Auto Generated Program Module
#
# Plugins::remove_links
# Author : Dean Browett
# Version : 0.1
# Updated : Fri Apr 12 14:28:21 2002
#
# ==================================================================
#

package Plugins::remove_links;
# ==================================================================

use strict;
use GT::Date qw/:all/;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;

# Inherit from base class for debug and error methods
@Plugins::remove_links::ISA = qw(GT::Base);

sub update_links {
# Your code begins here! Good Luck!
my $args = shift;


my $table = $DB->table('Links');

my $sth = $table->select ( ['ID','LinkOwner','Add_Date','Directory'] );

my $concerts = 'concerts';
my $courses = 'courses';
my $result;

my $cond1 = GT::SQL::Condition->new ('Directory','=',$concerts, 'Directory','=',$courses);
$cond1->bool('or');

while (my $row = $sth->fetchrow_hashref) {

my $cond2 = GT::SQL::Condition->new ('ID','=',$row->{ID}, $cond1 );

my $diff = GT::Date::date_diff(GT::Date::date_get_gm(),$row->{Add_Date});

if ($diff > 2) {
$result = $table->delete($cond2);
if (! (defined $result)) {
printf FYL "ERROR DELETING LINK: %d, %s\n", $row->{ID}, $row->{LinkOwner};
}
}

}
GT::Plugins->action ( CONTINUE );

return $args;

}
# Always end with a 1.
1;


The program always bombs out on line 179 of Links/Link.pm after what looks like a number of iterations:

$ret = $self->SUPER::delete ({ ID => $id }) if ($delete_link);



Can someone clear this up for me.

TIA

Dean
Subject Author Views Date
Thread problem deleting Links using plugin wobbly 2618 Apr 16, 2002, 6:10 AM
Thread Re: [wobbly] problem deleting Links using plugin
Paul 2495 Apr 16, 2002, 6:19 AM
Post Re: [Paul] problem deleting Links using plugin
Alex 2448 Apr 17, 2002, 3:21 PM