From b14d094d83dd3b338c981a92dd1b3795f30cdc44 Mon Sep 17 00:00:00 2001 From: f0o Date: Mon, 30 Nov 2015 18:51:22 +0000 Subject: [PATCH] Fix Glue-Expansion on alerts --- includes/alerts.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/alerts.inc.php b/includes/alerts.inc.php index 85b897ee6..fce14a701 100644 --- a/includes/alerts.inc.php +++ b/includes/alerts.inc.php @@ -123,8 +123,11 @@ function ResolveGlues($tables,$target,$x=0,$hist=array(),$last=array()) { $glues = dbFetchRows('SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ? && COLUMN_NAME LIKE "%\_id"',array($table)); if( sizeof($glues) == 1 && $glues[0]['COLUMN_NAME'] != $target ) { //Search for new candidates to expand - $tmp = dbFetchRows('SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME LIKE "'.substr($table,0,-1).'_%" && TABLE_NAME != "'.$table.'"'); $ntables = array(); + list($tmp) = explode('_',$glues[0]['COLUMN_NAME'],2); + $ntables[] = $tmp; + $ntables[] = $tmp.'s'; + $tmp = dbFetchRows('SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME LIKE "'.substr($table,0,-1).'_%" && TABLE_NAME != "'.$table.'"'); foreach( $tmp as $expand ) { $ntables[] = $expand['TABLE_NAME']; }