Changeset 449

Show
Ignore:
Timestamp:
07/03/08 20:18:21 (4 years ago)
Author:
dom
Message:

don't list internal links from nodes which don't exist

Location:
wiki-toolkit/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/Changes

    r446 r449  
    77        Changed Wiki::Toolkit::Feed::Listing to use metadata_was instead of 
    88          metadata_wasnt, for efficiency reasons. 
     9        list_dangling_links, list_backlinks: don't return internal links 
     10          that are from a node which does not exist. This works around 
     11          database inconsistencies (introduced by manual deletion of nodes) 
     12          which should be fixed by adding constraints to the database (see #38) 
    913 
    10140.75    11 May 2008 
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Database.pm

    r441 r449  
    388388    croak "Must supply a node name" unless $node; 
    389389    my $dbh = $self->dbh; 
    390     my $sql = "SELECT link_from FROM internal_links WHERE link_to=" 
     390    # XXX see comment in list_dangling_links 
     391    my $sql = "SELECT link_from FROM internal_links INNER JOIN 
     392               node AS node_from ON node_from.name=internal_links.link_from 
     393               WHERE link_to=" 
    391394            . $dbh->quote($node); 
    392395    my $sth = $dbh->prepare($sql); 
     
    413416    my $self = shift; 
    414417    my $dbh = $self->dbh; 
     418    # XXX this is really hiding an inconsistency in the database; 
     419    # should really fix the constraints so that this inconsistency 
     420    # cannot be introduced; also rework this table completely so 
     421    # that it uses IDs, not node names (will simplify rename_node too) 
    415422    my $sql = "SELECT DISTINCT internal_links.link_to 
    416                FROM internal_links LEFT JOIN node 
    417                                    ON node.name=internal_links.link_to 
    418                WHERE node.version IS NULL"; 
     423               FROM internal_links INNER JOIN node AS node_from ON 
     424               node_from.name=internal_links.link_from LEFT JOIN node 
     425               AS node_to ON node_to.name=internal_links.link_to 
     426               WHERE node_to.version IS NULL"; 
    419427    my $sth = $dbh->prepare($sql); 
    420428    $sth->execute or croak $dbh->errstr;