From ccfc16e296696ebdd0d047d0299e1d8ad17ef0bb Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Thu, 28 Aug 2014 16:01:53 +0000 Subject: [PATCH] Protect dashboards against invalid queries in "grouped by" dashlets. (retrofit from trunk) SVN:2.0.2[3310] --- application/dashlet.class.inc.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index 0f68bbf24..a0aec01bb 100644 --- a/application/dashlet.class.inc.php +++ b/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)) {