From 48f2caccae987a242912d4f17e87ebe3043c70f2 Mon Sep 17 00:00:00 2001 From: Martynas Mickevicius Date: Thu, 8 Jul 2010 20:26:40 +0300 Subject: [PATCH] error handling --- libraries/chart.lib.php | 14 ++++++++++++-- libraries/chart/pma_chart.php | 10 ++++++++++ libraries/chart/pma_pchart_chart.php | 3 ++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libraries/chart.lib.php b/libraries/chart.lib.php index 6855dd12b..68639fff9 100644 --- a/libraries/chart.lib.php +++ b/libraries/chart.lib.php @@ -36,7 +36,9 @@ function PMA_chart_status($data) $chart = new PMA_pChart_Pie( __('Query statistics'), array_slice($chartData, 0, 20, true)); - echo $chart->toString(); + $chartCode = $chart->toString(); + PMA_handle_chart_err($chart->getErrors()); + echo $chartCode; } /* @@ -54,7 +56,9 @@ function PMA_chart_profiling($data) $chart = new PMA_pChart_Pie( __('Query execution time comparison (in microseconds)'), $chartData); - echo $chart->toString(); + $chartCode = $chart->toString(); + PMA_handle_chart_err($chart->getErrors()); + echo $chartCode; } /* @@ -205,7 +209,13 @@ function PMA_chart_results($data, &$chartSettings) $chartCode = $chart->toString(); $chartSettings = $chart->getSettings(); + PMA_handle_chart_err($chart->getErrors()); return $chartCode; } +function PMA_handle_chart_err($errors) +{ + PMA_warnMissingExtension('GD', false, 'GD extension is needed for charts.'); +} + ?> diff --git a/libraries/chart/pma_chart.php b/libraries/chart/pma_chart.php index 735b0a484..5baf2bd38 100644 --- a/libraries/chart/pma_chart.php +++ b/libraries/chart/pma_chart.php @@ -71,6 +71,11 @@ class PMA_Chart */ private $userSpecifiedSettings = null; + /* + * Error codes will be stored here + */ + protected $errors = null; + function __construct($options = null) { $this->userSpecifiedSettings = $options; @@ -133,6 +138,11 @@ class PMA_Chart { return $this->settings; } + + public function getErrors() + { + return $this->errors; + } } ?> diff --git a/libraries/chart/pma_pchart_chart.php b/libraries/chart/pma_pchart_chart.php index 8965ee62f..710a60fc0 100644 --- a/libraries/chart/pma_pchart_chart.php +++ b/libraries/chart/pma_pchart_chart.php @@ -136,7 +136,8 @@ abstract class PMA_pChart_Chart extends PMA_Chart return ''; } else { - return __('GD library needed for chart is missing.'); + $this->errors = 1; // stub + return ''; } }