[BUGFIX] Install tool: strict_types fatal in environment 97/53797/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 23 Aug 2017 19:51:03 +0000 (21:51 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 24 Aug 2017 07:41:36 +0000 (09:41 +0200)
If im / gm are not configured, the Environment module may
throw a fatal since refactoring. The patch sanitizes that
and fixes the "Current configuration" view in
"Image Processing" card which broke during refactoring, too.

Change-Id: I6180a10150e63182c23dd7d7e8257e99a8652533
Resolves: #82160
Related: #76084
Releases: master
Reviewed-on: https://review.typo3.org/53797
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/install/Classes/Controller/Action/Tool/Environment.php
typo3/sysext/install/Resources/Private/Partials/Action/Tool/Environment/ImageProcessing.html

index 2857016..f740add 100644 (file)
@@ -41,8 +41,15 @@ class Environment extends Action\AbstractAction
             'folderStructureFilePermissionStatus' => $permissionCheck->getMaskStatus('fileCreateMask'),
             'folderStructureDirectoryPermissionStatus' => $permissionCheck->getMaskStatus('folderCreateMask'),
 
-            'imageProcessingConfiguration' => $this->getImageConfiguration(),
             'imageProcessingToken' => $formProtection->generateToken('installTool', 'imageProcessing'),
+            'imageProcessingProcessor' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor'] === 'GraphicsMagick' ? 'GraphicsMagick' : 'ImageMagick',
+            'imageProcessingEnabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_enabled'],
+            'imageProcessingPath' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'],
+            'imageProcessingVersion' => $this->determineImageMagickVersion(),
+            'imageProcessingEffects' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_effects'],
+            'imageProcessingGdlibEnabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'],
+            'imageProcessingGdlibPng' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'],
+            'imageProcessingFileFormats' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
 
             'mailTestToken' => $formProtection->generateToken('installTool', 'mailTest'),
             'mailTestSenderAddress' => $this->getSenderEmailAddress(),
@@ -55,25 +62,6 @@ class Environment extends Action\AbstractAction
     }
 
     /**
-     * Gather image configuration overview
-     *
-     * @return array Result array
-     */
-    protected function getImageConfiguration(): array
-    {
-        return [
-            'processor' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor'] === 'GraphicsMagick' ? 'GraphicsMagick' : 'ImageMagick',
-            'processorEnabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_enabled'],
-            'processorPath' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'],
-            'processorVersion' => $this->determineImageMagickVersion(),
-            'processorEffects' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_effects'],
-            'gdlibEnabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'],
-            'gdlibPng' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'],
-            'fileFormats' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
-        ];
-    }
-
-    /**
      * Determine ImageMagick / GraphicsMagick version
      *
      * @return string Version
@@ -83,9 +71,13 @@ class Environment extends Action\AbstractAction
         $command = CommandUtility::imageMagickCommand('identify', '-version');
         CommandUtility::exec($command, $result);
         $string = $result[0];
-        list(, $version) = explode('Magick', $string);
-        list($version) = explode(' ', trim($version));
-        return trim($version);
+        $version = '';
+        if (!empty($string)) {
+            list(, $version) = explode('Magick', $string);
+            list($version) = explode(' ', trim($version));
+            $version = trim($version);
+        }
+        return $version;
     }
 
     /**
index 67fff9d..0c873bd 100644 (file)
                                <table class="table table-striped">
                                        <tr>
                                                <td>
-                                                       {imageConfiguration.processor} enabled:
+                                                       {imageProcessingProcessor} enabled:
                                                </td>
                                                <td>
-                                                       {f:if(condition:imageConfiguration.processorEnabled, then:'Yes', else:'No')}
+                                                       {f:if(condition:imageProcessingEnabled, then:'Yes', else:'No')}
                                                </td>
                                        </tr>
                                        <tr>
                                                        ImageMagick or GraphicsMagick:
                                                </td>
                                                <td>
-                                                       {imageConfiguration.processor}
+                                                       {imageProcessingProcessor}
                                                </td>
                                        </tr>
                                        <tr>
                                                <td>
-                                                       {imageConfiguration.processor} path:
+                                                       {imageProcessingProcessor} path:
                                                </td>
                                                <td>
-                                                       {imageConfiguration.processorPath}
+                                                       {imageProcessingPath}
                                                </td>
                                        </tr>
                                        <tr>
                                                <td>
-                                                       {imageConfiguration.processor} version:
+                                                       {imageProcessingProcessor} version:
                                                </td>
                                                <td>
-                                                       {imageConfiguration.processorVersion}
+                                                       {imageProcessingVersion}
                                                </td>
                                        </tr>
                                        <tr>
                                                <td>
-                                                       {imageConfiguration.processor} effects enabled:
+                                                       {imageProcessingProcessor} effects enabled:
                                                </td>
                                                <td>
-                                                       {imageConfiguration.processorEffects} <span>(Blurring/Sharpening with {imageConfiguration.processor})</span>
+                                                       {imageProcessingEffects} <span>(Blurring/Sharpening with {imageProcessingProcessor})</span>
                                                </td>
                                        </tr>
                                        <tr>
                                                        GDLib enabled:
                                                </td>
                                                <td>
-                                                       {f:if(condition:imageConfiguration.gdlibEnabled, then:'Yes', else:'No')}
+                                                       {f:if(condition:imageProcessingGdlibEnabled, then:'Yes', else:'No')}
                                                </td>
                                        </tr>
                                        <tr>
                                                        GDLib using PNG:
                                                </td>
                                                <td>
-                                                       {imageConfiguration.gdlibPng}
-                                               </td>
-                                       </tr>
-                                       <tr>
-                                               <td>
-                                                       Freetype DPI:
-                                               </td>
-                                               <td>
-                                                       {imageConfiguration.freeTypeDpi} <span>(Should be 96 for Freetype 2)</span>
+                                                       {f:if(condition:imageProcessingGdlibPng, then:'Yes', else:'No')}
                                                </td>
                                        </tr>
                                        <tr>
                                                        File Formats:
                                                </td>
                                                <td>
-                                                       {imageConfiguration.fileFormats}
+                                                       {imageProcessingFileFormats}
                                                </td>
                                        </tr>
                                </table>