Skip to content
Extraits de code Groupes Projets
Valider 1b3d7ff9 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Catch exceptions when getting individual reports during scheduled reports...

Catch exceptions when getting individual reports during scheduled reports generation so reports will still be sent even if individual reports fail in some way.
parent cb1c8f10
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -26,6 +26,9 @@ use Piwik\Site; ...@@ -26,6 +26,9 @@ use Piwik\Site;
use Piwik\Tracker; use Piwik\Tracker;
use Piwik\Translate; use Piwik\Translate;
use Piwik\Translation\Translator; 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. * The ScheduledReports API lets you manage Scheduled Email reports, as well as generate, download or email any existing report.
...@@ -60,6 +63,16 @@ class API extends \Piwik\Plugin\API ...@@ -60,6 +63,16 @@ class API extends \Piwik\Plugin\API
// static cache storing reports // static cache storing reports
public static $cache = array(); public static $cache = array();
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/** /**
* Creates a new report and schedules it. * Creates a new report and schedules it.
* *
...@@ -377,7 +390,20 @@ class API extends \Piwik\Plugin\API ...@@ -377,7 +390,20 @@ class API extends \Piwik\Plugin\API
$params['segment'] = false; $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; $processedReport['segment'] = $segment;
// TODO add static method getPrettyDate($period, $date) in Period // TODO add static method getPrettyDate($period, $date) in Period
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter