Changeset 186


Ignore:
Timestamp:
12/06/11 13:51:18 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Add some more loop-breaking to isParent() to break infinite loops
that cause *big* messes in the error log (see #25)

  • just return 0 on parent == 0, 1 on child == 0
  • break the while() if the fetch returns no results, otherwise we end up trying to retrieve records for id=<undef>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r185 r186  
    14991499  return 0 if $type1 eq 'domain' && $type2 ne 'record'; # domain may not be a parent of anything other than a record
    15001500
     1501  # ennnhhhh....  if we're passed an id of 0, it will never be found.  usual
     1502  # case would be the UI creating a new <thing>, and so we don't have an ID for
     1503  # <thing> to look up yet.  in that case the UI should check the parent as well.
     1504  # argument for returning 1 is
     1505  return 0 if $id1 == 0;        # nothing can have a parent id of 0
     1506  return 1 if $id2 == 0;        # anything could have a child id of 0 (or "unknown")
     1507
    15011508  # group 1 is the ultimate root parent
    15021509  return 1 if $type1 eq 'group' && $id1 == 1;
     
    15101517  my $foundparent = 0;
    15111518
     1519  my $limiter = 0;
    15121520  while (1) {
    15131521    my $sql = "SELECT $par_col{$type} FROM $par_tbl{$type} WHERE $id_col{$type} = ?";
    15141522    my $result = $dbh->selectrow_hashref($sql,
    15151523        undef, ($id) );
     1524    if (!$result) {
     1525      $limiter++;
     1526##fixme:  how often will this happen on a live site?
     1527      warn "no results looking for $sql with id $id (depth $limiter)\n";
     1528      last;
     1529    }
    15161530    if ($result && $result->{$par_col{$type}} == $id1) {
    15171531      $foundparent = 1;
Note: See TracChangeset for help on using the changeset viewer.