From ae3f893351b1af886d9ee999d58d07330fcb4050 Mon Sep 17 00:00:00 2001 From: f0o Date: Mon, 30 Nov 2015 19:13:32 +0000 Subject: [PATCH] Remove now obsoleted naive glue-checks --- includes/alerts.inc.php | 43 +++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/includes/alerts.inc.php b/includes/alerts.inc.php index fce14a701..9d8dfa923 100644 --- a/includes/alerts.inc.php +++ b/includes/alerts.inc.php @@ -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++; }