[TASK] Add a system check for external downloads 86/30486/3
authorMarkus Klein <klein.t3@mfc-linz.at>
Thu, 29 May 2014 13:00:15 +0000 (15:00 +0200)
committerXavier Perseguers <xavier@typo3.org>
Thu, 12 Jun 2014 07:05:42 +0000 (09:05 +0200)
This patch adds a check to the SystemEnvironment checks to test
whether any method for retrieving external files is available.
This involves allow_url_fopen PHP setting and the usage of curl.
Either of these two must be available otherwise any download
(e.g. from TER) fails.

Resolves: #58316
Releases: 6.2
Change-Id: I7dd7d2d7d2ce102723af3315f4ad4342610b4147
Reviewed-on: https://review.typo3.org/30486
Reviewed-by: Stefan Neufeind
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Fabien Udriot
Reviewed-by: Marcin SÄ…gol
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/install/Classes/SystemEnvironment/Check.php

index d4cdba6..1756eaa 100644 (file)
@@ -94,6 +94,7 @@ class Check {
                $statusArray[] = $this->checkPhpVersion();
                $statusArray[] = $this->checkMaxExecutionTime();
                $statusArray[] = $this->checkDisableFunctions();
+               $statusArray[] = $this->checkDownloadsPossible();
                $statusArray[] = $this->checkSafeMode();
                $statusArray[] = $this->checkDocRoot();
                $statusArray[] = $this->checkOpenBaseDir();
@@ -405,6 +406,28 @@ class Check {
        }
 
        /**
+        * Check if it is possible to download external data (e.g. TER)
+        * Either allow_url_fopen must be enabled or curl must be used
+        *
+        * @return Status\OkStatus|Status\WarningStatus
+        */
+       protected function checkDownloadsPossible() {
+               $allowUrlFopen = (bool)ini_get('allow_url_fopen');
+               $curlEnabled = !empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse']);
+               if ($allowUrlFopen || $curlEnabled) {
+                       $status = new Status\OkStatus();
+                       $status->setTitle('Fetching external URLs is allowed');
+               } else {
+                       $status = new Status\WarningStatus();
+                       $status->setTitle('Fetching external URLs is not allowed');
+                       $status->setMessage(
+                               'Either enable PHP runtime setting "allow_url_fopen"' . LF .  'or enable curl by setting [SYS][curlUse] accordingly.'
+                       );
+               }
+               return $status;
+       }
+
+       /**
         * Check if safe mode is enabled
         *
         * @return Status\StatusInterface