[BUGFIX] Check for imageftbbox() existence before usage 83/21783/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 2 Jul 2013 08:39:05 +0000 (10:39 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 2 Jul 2013 09:00:07 +0000 (11:00 +0200)
Install tool system environment check calls imageftbbox() without
checking if the function exists and may fatal. The patch adds a
function_exists() and introduces an error status message.

Resolves: #49458
Releases: 6.2

Change-Id: Ibb3be59d6506632db18d68e3394fd5a4b048da81
Reviewed-on: https://review.typo3.org/21783
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Alexander Schnitzler
Tested-by: Alexander Schnitzler
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/install/Classes/SystemEnvironment/Check.php

index a886160..baadf64 100644 (file)
@@ -983,33 +983,38 @@ class Check {
         * @return Status\OkStatus|Status\NoticeStatus
         */
        protected function isTrueTypeFontDpiStandard() {
-               // 20 Pixels at 96 DPI - the DefaultConfiguration
-               $fontSize = (20 / 96 * 72);
-
-               $textDimensions = @imageftbbox(
-                       $fontSize,
-                       0,
-                       __DIR__ . '/../../Resources/Private/Font/vera.ttf',
-                       'Testing true type support'
-               );
-               $fontBoxWidth = $textDimensions[2] - $textDimensions[0];
-
-               if ($fontBoxWidth < 300 && $fontBoxWidth > 200) {
-                       $status = new Status\OkStatus();
-                       $status->setTitle('FreeType True Type Font DPI');
-                       $status->setMessage('Fonts are rendered by FreeType library. ' .
+               if (function_exists('imageftbbox')) {
+                       // 20 Pixels at 96 DPI - the DefaultConfiguration
+                       $fontSize = (20 / 96 * 72);
+                       $textDimensions = @imageftbbox(
+                               $fontSize,
+                               0,
+                               __DIR__ . '/../../Resources/Private/Font/vera.ttf',
+                               'Testing true type support'
+                       );
+                       $fontBoxWidth = $textDimensions[2] - $textDimensions[0];
+                       if ($fontBoxWidth < 300 && $fontBoxWidth > 200) {
+                               $status = new Status\OkStatus();
+                               $status->setTitle('FreeType True Type Font DPI');
+                               $status->setMessage('Fonts are rendered by FreeType library. ' .
                                        'We need to ensure that the final dimensions are as expected. ' .
                                        'This server renderes fonts based on 96 DPI correctly'
-                       );
-
-               } else {
-                       $status = new Status\NoticeStatus();
-                       $status->setTitle('FreeType True Type Font DPI');
-                       $status->setMessage('Fonts are rendered by FreeType library. ' .
+                               );
+                       } else {
+                               $status = new Status\NoticeStatus();
+                               $status->setTitle('FreeType True Type Font DPI');
+                               $status->setMessage('Fonts are rendered by FreeType library. ' .
                                        'This server renders fonts not as expected. ' .
                                        'Please configure FreeType or TYPO3_CONF_VARS[GFX][TTFdpi]'
+                               );
+                       }
+               } else {
+                       $status = new Status\ErrorStatus();
+                       $status->setTitle('PHP GD library freetype2 support missing');
+                       $status->setMessage(
+                               'The core relies on GD library compiled into PHP with freetype2' .
+                               ' support. This is missing on your system. Please install it.'
                        );
-
                }
 
                return $status;