Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-09-05 05:39:53 +0300
committerdiosmosis <benaka@piwik.pro>2015-09-10 23:35:21 +0300
commit1b3d7ff9bda710f9c840ba38b8f65d4aec0bae50 (patch)
treed2aa9c00abeceffffa781bc265bdcb2eb89e776f /plugins/ScheduledReports
parentcb1c8f109c82d99968301ed2a1de5e99c50b2f9f (diff)
Catch exceptions when getting individual reports during scheduled reports generation so reports will still be sent even if individual reports fail in some way.
Diffstat (limited to 'plugins/ScheduledReports')
-rw-r--r--plugins/ScheduledReports/API.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/plugins/ScheduledReports/API.php b/plugins/ScheduledReports/API.php
index f77fa4b223..d5a985e65b 100644
--- a/plugins/ScheduledReports/API.php
+++ b/plugins/ScheduledReports/API.php
@@ -26,6 +26,9 @@ use Piwik\Site;
use Piwik\Tracker;
use Piwik\Translate;
use Piwik\Translation\Translator;
+use Piwik\Url;
+use Piwik\UrlHelper;
+use Psr\Log\LoggerInterface;
/**
* The ScheduledReports API lets you manage Scheduled Email reports, as well as generate, download or email any existing report.
@@ -61,6 +64,16 @@ class API extends \Piwik\Plugin\API
public static $cache = array();
/**
+ * @var LoggerInterface
+ */
+ private $logger;
+
+ public function __construct(LoggerInterface $logger)
+ {
+ $this->logger = $logger;
+ }
+
+ /**
* Creates a new report and schedules it.
*
* @param int $idSite
@@ -377,7 +390,20 @@ class API extends \Piwik\Plugin\API
$params['segment'] = false;
}
- $processedReport = Request::processRequest('API.getProcessedReport', $params);
+ try {
+ $processedReport = Request::processRequest('API.getProcessedReport', $params);
+ } catch (\Exception $ex) {
+ // NOTE: can't use warning or error because the log message will appear in the UI as a notification
+ $this->logger->info("Error getting '?{report}' when generating scheduled report: {exception}", array(
+ 'report' => http_build_query($params),
+ 'exception' => $ex->getMessage(),
+ ));
+
+ $this->logger->debug($ex);
+
+ continue;
+ }
+
$processedReport['segment'] = $segment;
// TODO add static method getPrettyDate($period, $date) in Period