Browse Source

Protect dashboards against invalid queries in "grouped by" dashlets.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3304 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 10 years ago
parent
commit
0940b35dbf
1 changed files with 13 additions and 5 deletions
  1. 13 5
      application/dashlet.class.inc.php

+ 13 - 5
application/dashlet.class.inc.php

@@ -506,11 +506,19 @@ abstract class DashletGroupBy extends Dashlet
 		$sGroupBy = $this->aProperties['group_by'];
 		$sStyle = $this->aProperties['style'];
 
-		// First perform the query - if the OQL is not ok, it will generate an exception : no need to go further 
-		$oQuery = $this->oModelReflection->GetQuery($sQuery);
-		$sClass = $oQuery->GetClass();
-		$sClassAlias = $oQuery->GetClassAlias();
-
+		// First perform the query - if the OQL is not ok, it will generate an exception : no need to go further
+		try
+		{
+			$oQuery = $this->oModelReflection->GetQuery($sQuery);
+			$sClass = $oQuery->GetClass();
+			$sClassAlias = $oQuery->GetClassAlias();
+		}
+		catch(Exception $e)
+		{
+			// Invalid query, let the user edit the dashlet/dashboard anyhow
+			$sClass = '';
+			$sClassAlias = '';
+		}
 		// Check groupby... it can be wrong at this stage
 		if (preg_match('/^(.*):(.*)$/', $sGroupBy, $aMatches))
 		{