[TASK] Add verbose output to report mail for failed tests 00/33400/5
authorBenedict Burckhart <info@bebuso.de>
Mon, 20 Oct 2014 15:45:55 +0000 (17:45 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Mon, 3 Nov 2014 15:00:23 +0000 (16:00 +0100)
Adds the failed tests messages to the mail.

Change-Id: I104b7ad98b2ce1ab8014a0751f7adc8c72ad6ca2
Resolves: #58786
Related: #62101
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/33400
Reviewed-by: Benedict Burckhart <bb@code-plant.de>
Reviewed-by: Frederic Gaus <gaus@flagbit.de>
Tested-by: Frederic Gaus <gaus@flagbit.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/install/Classes/Report/EnvironmentStatusReport.php
typo3/sysext/reports/Classes/ExtendedStatusProviderInterface.php [new file with mode: 0644]
typo3/sysext/reports/Classes/Report/Status/Status.php
typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php

index f26bf53..3ea7ffe 100644 (file)
@@ -14,20 +14,40 @@ namespace TYPO3\CMS\Install\Report;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Reports\ExtendedStatusProviderInterface;
+use TYPO3\CMS\Reports\StatusProviderInterface;
+
 /**
  * Provides an environment status report
  *
  * @author Christian Kuhn <lolli@schwarzbu.ch>
  */
-class EnvironmentStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface {
+class EnvironmentStatusReport implements StatusProviderInterface, ExtendedStatusProviderInterface {
 
        /**
         * Compile environment status report
         *
-        * @throws \TYPO3\CMS\Install\Exception
-        * @return array<\TYPO3\CMS\Reports\Status>
+        * @return \TYPO3\CMS\Reports\Status[]
         */
        public function getStatus() {
+               return $this->getStatusInternal(FALSE);
+       }
+
+       /**
+        * Returns the detailed status of an extension or (sub)system
+        *
+        * @return \TYPO3\CMS\Reports\Status[]
+        */
+       public function getDetailedStatus() {
+               return $this->getStatusInternal(TRUE);
+       }
+
+       /**
+        * @param $verbose
+        * @return \TYPO3\CMS\Reports\Status[]
+        * @throws \TYPO3\CMS\Install\Exception
+        */
+       protected function getStatusInternal($verbose) {
                /** @var $statusCheck \TYPO3\CMS\Install\SystemEnvironment\Check */
                $statusCheck = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
                $statusObjects = $statusCheck->getStatus();
@@ -52,13 +72,22 @@ class EnvironmentStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterf
                $statusArray = array();
                foreach ($reportStatusTypes as $type => $statusObjects) {
                        $value = count($statusObjects);
+                       $message = '';
+                       if ($verbose) {
+                               foreach ($statusObjects as $statusObject) {
+                                       $message .= '### ' . $statusObject->getTitle() . ': ' . $statusObject->getSeverity() . CRLF;
+                               }
+                       }
+
                        if ($value > 0) {
                                $pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
                                // Map information type to abbreviation which is used in \TYPO3\CMS\Reports\Status class
                                if ($type === 'information') {
                                        $type = 'info';
                                }
-                               $message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
+                               if (!$verbose) {
+                                       $message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
+                               }
                                $severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
                                $statusArray[] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
                                        'TYPO3\\CMS\\Reports\\Status',
@@ -72,4 +101,5 @@ class EnvironmentStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterf
 
                return $statusArray;
        }
+
 }
diff --git a/typo3/sysext/reports/Classes/ExtendedStatusProviderInterface.php b/typo3/sysext/reports/Classes/ExtendedStatusProviderInterface.php
new file mode 100644 (file)
index 0000000..bcf592a
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace TYPO3\CMS\Reports;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Interface for classes which provide a status report entry.
+ *
+ * @author Markus Klein <klein.t3@reelworx.at>
+ */
+interface ExtendedStatusProviderInterface {
+
+       /**
+        * Returns the detailed status of an extension or (sub)system
+        *
+        * @return \TYPO3\CMS\Reports\Status[]
+        */
+       public function getDetailedStatus();
+
+}
index bdc7f2a..ae4cb10 100644 (file)
@@ -13,15 +13,20 @@ namespace TYPO3\CMS\Reports\Report\Status;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Reports\ExtendedStatusProviderInterface;
+use TYPO3\CMS\Reports\ReportInterface;
+use TYPO3\CMS\Reports\StatusProviderInterface;
+
 /**
  * The status report
  *
  * @author Ingo Renner <ingo@typo3.org>
  */
-class Status implements \TYPO3\CMS\Reports\ReportInterface {
+class Status implements ReportInterface {
 
        /**
-        * @var array
+        * @var StatusProviderInterface[][]
         */
        protected $statusProviders = array();
 
@@ -59,7 +64,7 @@ class Status implements \TYPO3\CMS\Reports\ReportInterface {
                        $this->statusProviders[$key] = array();
                        foreach ($statusProvidersList as $statusProvider) {
                                $statusProviderInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($statusProvider);
-                               if ($statusProviderInstance instanceof \TYPO3\CMS\Reports\StatusProviderInterface) {
+                               if ($statusProviderInstance instanceof StatusProviderInterface) {
                                        $this->statusProviders[$key][] = $statusProviderInstance;
                                }
                        }
@@ -69,7 +74,7 @@ class Status implements \TYPO3\CMS\Reports\ReportInterface {
        /**
         * Runs through all status providers and returns all statuses collected.
         *
-        * @return array An array of \TYPO3\CMS\Reports\Status objects
+        * @return \TYPO3\CMS\Reports\Status[]
         */
        public function getSystemStatus() {
                $status = array();
@@ -84,6 +89,25 @@ class Status implements \TYPO3\CMS\Reports\ReportInterface {
        }
 
        /**
+        * Runs through all status providers and returns all statuses collected, which are detailed.
+        *
+        * @return \TYPO3\CMS\Reports\Status[]
+        */
+       public function getDetailedSystemStatus() {
+               $status = array();
+               foreach ($this->statusProviders as $statusProviderId => $statusProviderList) {
+                       $status[$statusProviderId] = array();
+                       foreach ($statusProviderList as $statusProvider) {
+                               if ($statusProvider instanceof ExtendedStatusProviderInterface) {
+                                       $statuses = $statusProvider->getDetailedStatus();
+                                       $status[$statusProviderId] = array_merge($status[$statusProviderId], $statuses);
+                               }
+                       }
+               }
+               return $status;
+       }
+
+       /**
         * Determines the highest severity from the given statuses.
         *
         * @param array $statusCollection An array of \TYPO3\CMS\Reports\Status objects.
@@ -206,6 +230,7 @@ class Status implements \TYPO3\CMS\Reports\ReportInterface {
        protected function sortStatuses(array $statusCollection) {
                $statuses = array();
                $sortTitle = array();
+               $header = NULL;
                /** @var $status \TYPO3\CMS\Reports\Status */
                foreach ($statusCollection as $status) {
                        if ($status->getTitle() === 'TYPO3') {
index aa10b40..c15c0f8 100644 (file)
@@ -13,12 +13,18 @@ namespace TYPO3\CMS\Reports\Task;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\MailUtility;
+use TYPO3\CMS\Reports\Status;
+use TYPO3\CMS\Scheduler\Task\AbstractTask;
+
 /**
  * A task that should be run regularly to determine the system's status.
  *
  * @author Ingo Renner <ingo@typo3.org>
  */
-class SystemStatusUpdateTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
+class SystemStatusUpdateTask extends AbstractTask {
 
        /**
         * Email addresses to send email notification to in case we find problems with
@@ -37,13 +43,13 @@ class SystemStatusUpdateTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
         */
        public function execute() {
                /** @var $registry \TYPO3\CMS\Core\Registry */
-               $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
+               $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
                /** @var $statusReport \TYPO3\CMS\Reports\Report\Status\Status */
-               $statusReport = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Report\\Status\\Status');
-               $systemStatus = $statusReport->getSystemStatus();
+               $statusReport = GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Report\\Status\\Status');
+               $systemStatus = $statusReport->getDetailedSystemStatus();
                $highestSeverity = $statusReport->getHighestSeverity($systemStatus);
                $registry->set('tx_reports', 'status.highestSeverity', $highestSeverity);
-               if ($highestSeverity > \TYPO3\CMS\Reports\Status::OK) {
+               if ($highestSeverity > Status::OK) {
                        $this->sendNotificationEmail($systemStatus);
                }
                return TRUE;
@@ -71,19 +77,20 @@ class SystemStatusUpdateTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
        /**
         * Sends a notification email, reporting system issues.
         *
-        * @param array $systemStatus Array of statuses
+        * @param Status[] $systemStatus Array of statuses
         * @return void
         */
        protected function sendNotificationEmail(array $systemStatus) {
                $systemIssues = array();
                foreach ($systemStatus as $statusProvider) {
+                       /** @var Status $status */
                        foreach ($statusProvider as $status) {
-                               if ($status->getSeverity() > \TYPO3\CMS\Reports\Status::OK) {
-                                       $systemIssues[] = (string) $status;
+                               if ($status->getSeverity() > Status::OK) {
+                                       $systemIssues[] = (string)$status . CRLF . $status->getMessage() . CRLF . CRLF;
                                }
                        }
                }
-               $notificationEmails = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->notificationEmail, TRUE);
+               $notificationEmails = GeneralUtility::trimExplode(LF, $this->notificationEmail, TRUE);
                $sendEmailsTo = array();
                foreach ($notificationEmails as $notificationEmail) {
                        $sendEmailsTo[] = $notificationEmail;
@@ -96,9 +103,9 @@ class SystemStatusUpdateTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_issues') . ': ' . CRLF;
                $message .= implode(CRLF, $systemIssues);
                $message .= CRLF . CRLF;
-               $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
+               $from = MailUtility::getSystemFrom();
                /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
-               $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
+               $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
                $mail->setFrom($from);
                $mail->setTo($sendEmailsTo);
                $mail->setSubject($subject);