[BUGFIX] Create missing files/folders for ExtensionCompatibilityTester 35/53535/2
authorChristoph Bessei <typo3@bessei-it.eu>
Wed, 14 Jun 2017 19:56:34 +0000 (21:56 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Wed, 19 Jul 2017 07:38:28 +0000 (09:38 +0200)
* Create path to errorProtocolFile if it doesn't exist yet
* Create empty errorProtocolFile to avoid 404 errors

Resolves: #80547
Releases: master,8.7
Change-Id: I302909189d7ff4600325c91e525d9924810c4c5c
Reviewed-on: https://review.typo3.org/53535
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/install/Classes/Controller/Action/Ajax/ExtensionCompatibilityTester.php

index fb17410..8bb9f0e 100644 (file)
@@ -206,7 +206,7 @@ class ExtensionCompatibilityTester extends AbstractAjaxAction
         $incompatibleExtensions = $this->getExtensionsToExclude();
         $incompatibleExtensions = array_filter($incompatibleExtensions);
         $incompatibleExtensions = array_merge($incompatibleExtensions, [$extensionKey]);
-        GeneralUtility::writeFile($this->protocolFile, implode(', ', $incompatibleExtensions));
+        GeneralUtility::writeFileToTypo3tempDir($this->protocolFile, implode(', ', $incompatibleExtensions));
         $this->logError = true;
     }
 
@@ -231,14 +231,19 @@ class ExtensionCompatibilityTester extends AbstractAjaxAction
      */
     public function logError()
     {
+        $errors = [];
+
         // Logging is disabled.
         if (!$this->logError) {
+            // Create an empty file to avoid 404 errors
+            if (!is_file($this->errorProtocolFile)) {
+                GeneralUtility::writeFileToTypo3tempDir($this->errorProtocolFile, json_encode($errors));
+            }
             return;
         }
 
         // Fetch existing errors, add last one and write to file again.
         $lastError = error_get_last();
-        $errors = [];
 
         if (file_exists($this->errorProtocolFile)) {
             $errors = json_decode(file_get_contents($this->errorProtocolFile));
@@ -259,6 +264,6 @@ class ExtensionCompatibilityTester extends AbstractAjaxAction
         }
         $errors[] = $lastError;
 
-        GeneralUtility::writeFile($this->errorProtocolFile, json_encode($errors));
+        GeneralUtility::writeFileToTypo3tempDir($this->errorProtocolFile, json_encode($errors));
     }
 }