mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Remove now obsoleted naive glue-checks
This commit is contained in:
+18
-25
@@ -59,35 +59,28 @@ function GenSQL($rule) {
|
||||
$join = "";
|
||||
while( $i < $x ) {
|
||||
if( isset($tables[$i+1]) ) {
|
||||
if( dbFetchCell('SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_NAME = ? && COLUMN_NAME = ?',array($tables[$i+1],'device_id')) == 1 ) {
|
||||
//Found valid glue in definition.
|
||||
$join .= $tables[$i].".device_id = ".$tables[$i+1].".device_id && ";
|
||||
$gtmp = ResolveGlues(array($tables[$i+1]),'device_id');
|
||||
if( $gtmp === false ) {
|
||||
//Cannot resolve glue-chain. Rule is invalid.
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
//No valid glue, Resolve a glue-chain.
|
||||
$gtmp = ResolveGlues(array($tables[$i+1]),'device_id');
|
||||
if( $gtmp === false ) {
|
||||
//Cannot resolve glue-chain. Rule is invalid.
|
||||
return false;
|
||||
$last = "";
|
||||
$qry = "";
|
||||
foreach( $gtmp as $glue ) {
|
||||
if( empty($last) ) {
|
||||
list($tmp,$last) = explode('.',$glue);
|
||||
$qry .= $glue.' = ';
|
||||
}
|
||||
$last = "";
|
||||
$qry = "";
|
||||
foreach( $gtmp as $glue ) {
|
||||
if( empty($last) ) {
|
||||
list($tmp,$last) = explode('.',$glue);
|
||||
$qry .= $glue.' = ';
|
||||
}
|
||||
else {
|
||||
list($tmp,$new) = explode('.',$glue);
|
||||
$qry .= $tmp.'.'.$last.' && '.$tmp.'.'.$new.' = ';
|
||||
$last = $new;
|
||||
}
|
||||
if( !in_array($tmp, $tables) ) {
|
||||
$tables[] = $tmp;
|
||||
}
|
||||
else {
|
||||
list($tmp,$new) = explode('.',$glue);
|
||||
$qry .= $tmp.'.'.$last.' && '.$tmp.'.'.$new.' = ';
|
||||
$last = $new;
|
||||
}
|
||||
if( !in_array($tmp, $tables) ) {
|
||||
$tables[] = $tmp;
|
||||
}
|
||||
$join .= "( ".$qry.$tables[0].".device_id ) && ";
|
||||
}
|
||||
$join .= "( ".$qry.$tables[0].".device_id ) && ";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user