‪TYPO3CMS  ‪main
Check.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 
44 class ‪Check implements ‪CheckInterface
45 {
49  protected ‪$messageQueue;
50 
54  protected ‪$requiredPhpExtensions = [
55  'filter',
56  'gd',
57  'intl',
58  'json',
59  'libxml',
60  'mbstring',
61  'PDO',
62  'session',
63  'SPL',
64  'standard',
65  'tokenizer',
66  'xml',
67  'zip',
68  'zlib',
69  ];
70 
74  protected ‪$suggestedPhpExtensions = [
75  'fileinfo' => 'This extension is used for proper file type detection in the File Abstraction Layer.',
76  'openssl' => 'This extension is used for sending SMTP mails over an encrypted channel endpoint.',
77  ];
78 
79  public function ‪__construct()
80  {
81  $this->messageQueue = new ‪FlashMessageQueue('install');
82  }
83 
84  public function ‪getMessageQueue(): ‪FlashMessageQueue
85  {
87  }
88 
92  public function ‪getStatus(): FlashMessageQueue
93  {
97  $this->‪checkMemorySettings();
98  $this->‪checkPhpVersion();
99  $this->‪checkMaxExecutionTime();
100  $this->‪checkDisableFunctions();
101  $this->‪checkDocRoot();
102  $this->‪checkOpenBaseDir();
104 
105  $this->‪checkMaxInputVars();
108 
109  foreach ($this->requiredPhpExtensions as $extension) {
110  $this->‪checkPhpExtension($extension);
111  }
112 
113  foreach ($this->suggestedPhpExtensions as $extension => $purpose) {
114  $this->‪checkPhpExtension($extension, false, $purpose);
115  }
116 
117  $this->‪checkPcreVersion();
119  $this->‪checkGdLibGifSupport();
120  $this->‪checkGdLibJpgSupport();
121  $this->‪checkGdLibPngSupport();
123 
124  return ‪$this->messageQueue;
125  }
126 
130  protected function ‪checkCurrentDirectoryIsInIncludePath()
131  {
132  $includePath = (string)ini_get('include_path');
133  $delimiter = $this->‪isWindowsOs() ? ';' : ':';
134  $pathArray = ‪GeneralUtility::trimExplode($delimiter, $includePath, true);
135  if (!in_array('.', $pathArray)) {
136  $this->messageQueue->enqueue(new FlashMessage(
137  'include_path = ' . implode(' ', $pathArray) . LF
138  . 'Normally the current path \'.\' is included in the'
139  . ' include_path of PHP. Although TYPO3 does not rely on this,'
140  . ' it is an unusual setting that may introduce problems for'
141  . ' some extensions.',
142  'Current directory (./) is not within PHP include path',
143  ContextualFeedbackSeverity::WARNING
144  ));
145  } else {
146  $this->messageQueue->enqueue(new FlashMessage(
147  '',
148  'Current directory (./) is within PHP include path.'
149  ));
150  }
151  }
152 
156  protected function ‪checkFileUploadEnabled()
157  {
158  if (!ini_get('file_uploads')) {
159  $this->messageQueue->enqueue(new FlashMessage(
160  'file_uploads=' . ini_get('file_uploads') . LF
161  . 'TYPO3 uses the ability to upload files from the browser in various cases.'
162  . ' If this flag is disabled in PHP, you won\'t be able to upload files.'
163  . ' But it doesn\'t end here, because not only are files not accepted by'
164  . ' the server - ALL content in the forms are discarded and therefore'
165  . ' nothing at all will be editable if you don\'t set this flag!',
166  'File uploads not allowed in PHP',
167  ContextualFeedbackSeverity::ERROR
168  ));
169  } else {
170  $this->messageQueue->enqueue(new FlashMessage(
171  '',
172  'File uploads allowed in PHP'
173  ));
174  }
175  }
176 
181  {
182  $maximumUploadFilesize = $this->‪getBytesFromSizeMeasurement((string)ini_get('upload_max_filesize'));
183  $maximumPostSize = $this->‪getBytesFromSizeMeasurement((string)ini_get('post_max_size'));
184  if ($maximumPostSize > 0 && $maximumPostSize < $maximumUploadFilesize) {
185  $this->messageQueue->enqueue(new FlashMessage(
186  'upload_max_filesize=' . ini_get('upload_max_filesize') . LF
187  . 'post_max_size=' . ini_get('post_max_size') . LF
188  . 'You have defined a maximum size for file uploads in PHP which'
189  . ' exceeds the allowed size for POST requests. Therefore the'
190  . ' file uploads can also not be larger than ' . ini_get('post_max_size') . '.',
191  'Maximum size for POST requests is smaller than maximum upload filesize in PHP',
192  ContextualFeedbackSeverity::ERROR
193  ));
194  } elseif ($maximumPostSize === $maximumUploadFilesize) {
195  $this->messageQueue->enqueue(new FlashMessage(
196  'The maximum size for file uploads is set to ' . ini_get('upload_max_filesize'),
197  'Maximum post upload size correlates with maximum upload file size in PHP'
198  ));
199  } else {
200  $this->messageQueue->enqueue(new FlashMessage(
201  'The maximum size for file uploads is set to ' . ini_get('upload_max_filesize'),
202  'Maximum post upload size is higher than maximum upload file size in PHP, which is fine.'
203  ));
204  }
205  }
206 
210  protected function ‪checkMemorySettings()
211  {
212  $minimumMemoryLimit = 64;
213  $recommendedMemoryLimit = 128;
214  $memoryLimit = $this->‪getBytesFromSizeMeasurement((string)ini_get('memory_limit'));
215  if ($memoryLimit <= 0) {
216  $this->messageQueue->enqueue(new FlashMessage(
217  'PHP is configured not to limit memory usage at all. This is a risk'
218  . ' and should be avoided in production setup. In general it\'s best practice to limit this.'
219  . ' To be safe, set a limit in PHP, but with a minimum of ' . $recommendedMemoryLimit . 'MB:' . LF
220  . 'memory_limit=' . $recommendedMemoryLimit . 'M',
221  'Unlimited memory limit for PHP',
222  ContextualFeedbackSeverity::WARNING
223  ));
224  } elseif ($memoryLimit < 1024 * 1024 * $minimumMemoryLimit) {
225  $this->messageQueue->enqueue(new FlashMessage(
226  'memory_limit=' . ini_get('memory_limit') . LF
227  . 'Your system is configured to enforce a memory limit for PHP scripts lower than '
228  . $minimumMemoryLimit . 'MB. It is required to raise the limit.'
229  . ' We recommend a minimum PHP memory limit of ' . $recommendedMemoryLimit . 'MB:' . LF
230  . 'memory_limit=' . $recommendedMemoryLimit . 'M',
231  'PHP Memory limit below ' . $minimumMemoryLimit . 'MB',
232  ContextualFeedbackSeverity::ERROR
233  ));
234  } elseif ($memoryLimit < 1024 * 1024 * $recommendedMemoryLimit) {
235  $this->messageQueue->enqueue(new FlashMessage(
236  'memory_limit=' . ini_get('memory_limit') . LF
237  . 'Your system is configured to enforce a memory limit for PHP scripts lower than '
238  . $recommendedMemoryLimit . 'MB.'
239  . ' A slim TYPO3 instance without many extensions will probably work, but you should monitor your'
240  . ' system for "allowed memory size of X bytes exhausted" messages, especially if using the backend.'
241  . ' To be on the safe side, we recommend a minimum PHP memory limit of '
242  . $recommendedMemoryLimit . 'MB:' . LF
243  . 'memory_limit=' . $recommendedMemoryLimit . 'M',
244  'PHP Memory limit below ' . $recommendedMemoryLimit . 'MB',
245  ContextualFeedbackSeverity::WARNING
246  ));
247  } else {
248  $this->messageQueue->enqueue(new FlashMessage(
249  '',
250  'PHP Memory limit is equal to or more than ' . $recommendedMemoryLimit . 'MB'
251  ));
252  }
253  }
254 
258  protected function ‪checkPhpVersion()
259  {
260  $minimumPhpVersion = '8.1.0';
261  $currentPhpVersion = PHP_VERSION;
262  if (version_compare($currentPhpVersion, $minimumPhpVersion) < 0) {
263  $this->messageQueue->enqueue(new FlashMessage(
264  'Your PHP version ' . $currentPhpVersion . ' is too old. TYPO3 CMS does not run'
265  . ' with this version. Update to at least PHP ' . $minimumPhpVersion,
266  'PHP version too low',
267  ContextualFeedbackSeverity::ERROR
268  ));
269  } else {
270  $this->messageQueue->enqueue(new FlashMessage(
271  '',
272  'PHP version is fine'
273  ));
274  }
275  }
276 
280  protected function ‪checkPcreVersion()
281  {
282  $minimumPcreVersion = '8.38';
283  if (!extension_loaded('pcre')) {
284  $this->messageQueue->enqueue(new FlashMessage(
285  'TYPO3 CMS uses PHP extension pcre but it is not loaded'
286  . ' in your environment. Change your environment to provide this extension'
287  . ' in with minimum version ' . $minimumPcreVersion . '.',
288  'PHP extension pcre not loaded',
289  ContextualFeedbackSeverity::ERROR
290  ));
291  } else {
292  $installedPcreVersionString = trim(PCRE_VERSION); // '8.39 2016-06-14'
293  $mainPcreVersionString = explode(' ', $installedPcreVersionString);
294  $mainPcreVersionString = $mainPcreVersionString[0]; // '8.39'
295  if (version_compare($mainPcreVersionString, $minimumPcreVersion) < 0) {
296  $this->messageQueue->enqueue(new FlashMessage(
297  'Your PCRE version ' . PCRE_VERSION . ' is too old. TYPO3 CMS may trigger PHP segmentantion'
298  . ' faults with this version. Update to at least PCRE ' . $minimumPcreVersion,
299  'PCRE version too low',
300  ContextualFeedbackSeverity::ERROR
301  ));
302  } else {
303  $this->messageQueue->enqueue(new FlashMessage(
304  '',
305  'PHP extension PCRE is loaded and version is fine'
306  ));
307  }
308  }
309  }
310 
314  protected function ‪checkMaxExecutionTime()
315  {
316  $minimumMaximumExecutionTime = 30;
317  $recommendedMaximumExecutionTime = 240;
318  $currentMaximumExecutionTime = ini_get('max_execution_time');
319  if ($currentMaximumExecutionTime == 0) {
320  $this->messageQueue->enqueue(new FlashMessage(
321  'max_execution_time=0' . LF
322  . 'While TYPO3 is fine with this, you risk a denial-of-service for your system if for whatever'
323  . ' reason some script hangs in an infinite loop. You are usually on the safe side '
324  . ' if it is reduced to ' . $recommendedMaximumExecutionTime . ' seconds:' . LF
325  . 'max_execution_time=' . $recommendedMaximumExecutionTime,
326  'Infinite PHP script execution time',
327  ContextualFeedbackSeverity::WARNING
328  ));
329  } elseif ($currentMaximumExecutionTime < $minimumMaximumExecutionTime) {
330  $this->messageQueue->enqueue(new FlashMessage(
331  'max_execution_time=' . $currentMaximumExecutionTime . LF
332  . 'Your max_execution_time is too low. Some expensive operations in TYPO3 can take longer than that.'
333  . ' It is recommended to raise the limit to ' . $recommendedMaximumExecutionTime . ' seconds:' . LF
334  . 'max_execution_time=' . $recommendedMaximumExecutionTime,
335  'Low PHP script execution time',
336  ContextualFeedbackSeverity::ERROR
337  ));
338  } elseif ($currentMaximumExecutionTime < $recommendedMaximumExecutionTime) {
339  $this->messageQueue->enqueue(new FlashMessage(
340  'max_execution_time=' . $currentMaximumExecutionTime . LF
341  . 'Your max_execution_time is low. While TYPO3 often runs without problems'
342  . ' with ' . $minimumMaximumExecutionTime . ' seconds,'
343  . ' it may still happen that script execution is stopped before finishing'
344  . ' calculations. You should monitor the system for messages in this area'
345  . ' and maybe raise the limit to ' . $recommendedMaximumExecutionTime . ' seconds:' . LF
346  . 'max_execution_time=' . $recommendedMaximumExecutionTime,
347  'Low PHP script execution time',
348  ContextualFeedbackSeverity::WARNING
349  ));
350  } else {
351  $this->messageQueue->enqueue(new FlashMessage(
352  '',
353  'Maximum PHP script execution time is equal to or more than ' . $recommendedMaximumExecutionTime
354  ));
355  }
356  }
357 
361  protected function ‪checkDisableFunctions()
362  {
363  $disabledFunctions = trim((string)ini_get('disable_functions'));
364 
365  // Filter "disable_functions"
366  $disabledFunctionsArray = ‪GeneralUtility::trimExplode(',', $disabledFunctions, true);
367 
368  // Array with strings to find
369  $findStrings = [
370  // Disabled by default on Ubuntu OS but this is okay since the Core does not use them
371  'pcntl_',
372  ];
373  foreach ($disabledFunctionsArray as $key => $disabledFunction) {
374  foreach ($findStrings as $findString) {
375  if (str_contains($disabledFunction, $findString)) {
376  unset($disabledFunctionsArray[$key]);
377  }
378  }
379  }
380 
381  if ($disabledFunctions !== '') {
382  if (!empty($disabledFunctionsArray)) {
383  $this->messageQueue->enqueue(new FlashMessage(
384  'disable_functions=' . implode(' ', explode(',', $disabledFunctions)) . LF
385  . 'These function(s) are disabled. TYPO3 uses some of those, so there might be trouble.'
386  . ' TYPO3 is designed to use the default set of PHP functions plus some common extensions.'
387  . ' Possibly these functions are disabled'
388  . ' due to security considerations and most likely the list would include a function like'
389  . ' exec() which is used by TYPO3 at various places. Depending on which exact functions'
390  . ' are disabled, some parts of the system may just break without further notice.',
391  'Some PHP functions disabled',
392  ContextualFeedbackSeverity::ERROR
393  ));
394  } else {
395  $this->messageQueue->enqueue(new FlashMessage(
396  'disable_functions=' . implode(' ', explode(',', $disabledFunctions)) . LF
397  . 'These function(s) are disabled. TYPO3 uses currently none of those, so you are good to go.',
398  'Some PHP functions currently disabled but OK'
399  ));
400  }
401  } else {
402  $this->messageQueue->enqueue(new FlashMessage(
403  '',
404  'No disabled PHP functions'
405  ));
406  }
407  }
408 
412  protected function ‪checkDocRoot()
413  {
414  $docRootSetting = trim((string)ini_get('doc_root'));
415  if ($docRootSetting !== '') {
416  $this->messageQueue->enqueue(new FlashMessage(
417  'doc_root=' . $docRootSetting . LF
418  . 'PHP cannot execute scripts'
419  . ' outside this directory. This setting is seldom used and must correlate'
420  . ' with your actual document root. You might be in trouble if your'
421  . ' TYPO3 CMS core code is linked to some different location.'
422  . ' If that is a problem, the setting must be changed.',
423  'doc_root is set',
424  ContextualFeedbackSeverity::NOTICE
425  ));
426  } else {
427  $this->messageQueue->enqueue(new FlashMessage(
428  '',
429  'PHP doc_root is not set'
430  ));
431  }
432  }
433 
437  protected function ‪checkOpenBaseDir()
438  {
439  $openBaseDirSetting = trim((string)ini_get('open_basedir'));
440  if ($openBaseDirSetting !== '') {
441  $this->messageQueue->enqueue(new FlashMessage(
442  'open_basedir = ' . ini_get('open_basedir') . LF
443  . 'This restricts TYPO3 to open and include files only in this'
444  . ' path. Please make sure that this does not prevent TYPO3 from running,'
445  . ' if for example your TYPO3 CMS core is linked to a different directory'
446  . ' not included in this path.',
447  'PHP open_basedir is set',
448  ContextualFeedbackSeverity::NOTICE
449  ));
450  } else {
451  $this->messageQueue->enqueue(new FlashMessage(
452  '',
453  'PHP open_basedir is off'
454  ));
455  }
456  }
457 
461  protected function ‪checkXdebugMaxNestingLevel()
462  {
463  if (extension_loaded('xdebug')) {
464  $recommendedMaxNestingLevel = 400;
465  $errorThreshold = 250;
466  $currentMaxNestingLevel = ini_get('xdebug.max_nesting_level');
467  if ($currentMaxNestingLevel < $errorThreshold) {
468  $this->messageQueue->enqueue(new FlashMessage(
469  'xdebug.max_nesting_level=' . $currentMaxNestingLevel . LF
470  . 'This setting controls the maximum number of nested function calls to protect against'
471  . ' infinite recursion. The current value is too low for TYPO3 CMS and must'
472  . ' be either raised or xdebug has to be unloaded. A value of ' . $recommendedMaxNestingLevel
473  . ' is recommended. Warning: Expect fatal PHP errors in central parts of the CMS'
474  . ' if the value is not raised significantly to:' . LF
475  . 'xdebug.max_nesting_level=' . $recommendedMaxNestingLevel,
476  'PHP xdebug.max_nesting_level is critically low',
477  ContextualFeedbackSeverity::ERROR
478  ));
479  } elseif ($currentMaxNestingLevel < $recommendedMaxNestingLevel) {
480  $this->messageQueue->enqueue(new FlashMessage(
481  'xdebug.max_nesting_level=' . $currentMaxNestingLevel . LF
482  . 'This setting controls the maximum number of nested function calls to protect against'
483  . ' infinite recursion. The current value is high enough for the TYPO3 CMS core to work'
484  . ' fine, but still some extensions could raise fatal PHP errors if the setting is not'
485  . ' raised further. A value of ' . $recommendedMaxNestingLevel . ' is recommended.' . LF
486  . 'xdebug.max_nesting_level=' . $recommendedMaxNestingLevel,
487  'PHP xdebug.max_nesting_level is low',
488  ContextualFeedbackSeverity::WARNING
489  ));
490  } else {
491  $this->messageQueue->enqueue(new FlashMessage(
492  '',
493  'PHP xdebug.max_nesting_level ok'
494  ));
495  }
496  } else {
497  $this->messageQueue->enqueue(new FlashMessage(
498  '',
499  'PHP xdebug extension not loaded'
500  ));
501  }
502  }
503 
507  protected function ‪checkMaxInputVars()
508  {
509  $recommendedMaxInputVars = 1500;
510  $minimumMaxInputVars = 1000;
511  $currentMaxInputVars = ini_get('max_input_vars');
512 
513  if ($currentMaxInputVars < $minimumMaxInputVars) {
514  $this->messageQueue->enqueue(new FlashMessage(
515  'max_input_vars=' . $currentMaxInputVars . LF
516  . 'This setting can lead to lost information if submitting forms with lots of data in TYPO3 CMS'
517  . ' (as the install tool does). It is highly recommended to raise this'
518  . ' to at least ' . $recommendedMaxInputVars . ':' . LF
519  . 'max_input_vars=' . $recommendedMaxInputVars,
520  'PHP max_input_vars too low',
521  ContextualFeedbackSeverity::ERROR
522  ));
523  } elseif ($currentMaxInputVars < $recommendedMaxInputVars) {
524  $this->messageQueue->enqueue(new FlashMessage(
525  'max_input_vars=' . $currentMaxInputVars . LF
526  . 'This setting can lead to lost information if submitting forms with lots of data in TYPO3 CMS'
527  . ' (as the install tool does). It is highly recommended to raise this'
528  . ' to at least ' . $recommendedMaxInputVars . ':' . LF
529  . 'max_input_vars=' . $recommendedMaxInputVars,
530  'PHP max_input_vars very low',
531  ContextualFeedbackSeverity::WARNING
532  ));
533  } else {
534  $this->messageQueue->enqueue(new FlashMessage(
535  '',
536  'PHP max_input_vars ok'
537  ));
538  }
539  }
540 
544  protected function ‪checkReflectionDocComment()
545  {
546  $testReflection = new \ReflectionMethod(static::class, __FUNCTION__);
547  if ($testReflection->getDocComment() === false) {
548  $this->messageQueue->enqueue(new FlashMessage(
549  'TYPO3 CMS core extensions like extbase and fluid heavily rely on method'
550  . ' comment parsing to fetch annotations and add magic belonging to them.'
551  . ' This does not work in the current environment and so we cannot install'
552  . ' TYPO3 CMS.' . LF
553  . ' Here are some possibilities: ' . LF
554  . '* In Zend OPcache you can disable saving/loading comments. If you are using'
555  . ' Zend OPcache (included since PHP 5.5) then check your php.ini settings for'
556  . ' opcache.save_comments and opcache.load_comments and enable them.' . LF
557  . '* In Zend Optimizer+ you can disable saving comments. If you are using'
558  . ' Zend Optimizer+ then check your php.ini settings for'
559  . ' zend_optimizerplus.save_comments and enable it.' . LF
560  . '* The PHP extension eaccelerator is known to break this if'
561  . ' it is compiled without --with-eaccelerator-doc-comment-inclusion flag.'
562  . ' This compile flag must be specified, otherwise TYPO3 CMS will not work.' . LF
563  . 'For more information take a look in our documentation ' . ‪Typo3Information::URL_OPCACHE . '.',
564  'PHP Doc comment reflection broken',
565  ContextualFeedbackSeverity::ERROR
566  ));
567  } else {
568  $this->messageQueue->enqueue(new FlashMessage(
569  '',
570  'PHP Doc comment reflection works'
571  ));
572  }
573  }
574 
578  protected function ‪checkWindowsApacheThreadStackSize()
579  {
580  if ($this->‪isWindowsOs()
581  && str_starts_with($_SERVER['SERVER_SOFTWARE'], 'Apache')
582  ) {
583  $this->messageQueue->enqueue(new FlashMessage(
584  'This current value cannot be checked by the system, so please ignore this warning if it'
585  . ' is already taken care of: Fluid uses complex regular expressions which require a lot'
586  . ' of stack space during the first processing.'
587  . ' On Windows the default stack size for Apache is a lot smaller than on UNIX.'
588  . ' You can increase the size to 8MB (default on UNIX) by adding the following configuration'
589  . ' to httpd.conf and restarting Apache afterwards:' . LF
590  . '<IfModule mpm_winnt_module>ThreadStackSize 8388608</IfModule>',
591  'Windows apache thread stack size',
592  ContextualFeedbackSeverity::WARNING
593  ));
594  } else {
595  $this->messageQueue->enqueue(new FlashMessage(
596  '',
597  'Apache ThreadStackSize is not an issue on UNIX systems'
598  ));
599  }
600  }
601 
605  public function ‪checkPhpExtension(string $extension, bool $required = true, string $purpose = '')
606  {
607  if (!extension_loaded($extension)) {
608  $this->messageQueue->enqueue(new FlashMessage(
609  'TYPO3 uses the PHP extension "' . $extension . '" but it is not loaded'
610  . ' in your environment. Change your environment to provide this extension. '
611  . $purpose,
612  'PHP extension "' . $extension . '" not loaded',
613  $required ? ContextualFeedbackSeverity::ERROR : ContextualFeedbackSeverity::WARNING
614  ));
615  } else {
616  $this->messageQueue->enqueue(new FlashMessage(
617  '',
618  'PHP extension "' . $extension . '" loaded'
619  ));
620  }
621  }
622 
626  protected function ‪checkGdLibTrueColorSupport()
627  {
628  if (function_exists('imagecreatetruecolor')) {
629  $imageResource = @imagecreatetruecolor(50, 100);
630  if ($this->‪checkImageResource($imageResource)) {
631  imagedestroy($imageResource);
632  $this->messageQueue->enqueue(new FlashMessage(
633  '',
634  'PHP GD library true color works'
635  ));
636  } else {
637  $this->messageQueue->enqueue(new FlashMessage(
638  'GD is loaded, but calling imagecreatetruecolor() fails.'
639  . ' This must be fixed, TYPO3 CMS won\'t work well otherwise.',
640  'PHP GD library true color support broken',
641  ContextualFeedbackSeverity::ERROR
642  ));
643  }
644  } else {
645  $this->messageQueue->enqueue(new FlashMessage(
646  'Gdlib is essential for TYPO3 CMS to work properly.',
647  'PHP GD library true color support missing',
648  ContextualFeedbackSeverity::ERROR
649  ));
650  }
651  }
652 
656  protected function ‪checkGdLibGifSupport()
657  {
658  if (function_exists('imagecreatefromgif')
659  && function_exists('imagegif')
660  && (imagetypes() & IMG_GIF)
661  ) {
662  // Do not use data:// wrapper to be independent of allow_url_fopen
663  $imageResource = @imagecreatefromgif(__DIR__ . '/../../Resources/Public/Images/TestInput/Test.gif');
664  if ($this->‪checkImageResource($imageResource)) {
665  imagedestroy($imageResource);
666  $this->messageQueue->enqueue(new FlashMessage(
667  '',
668  'PHP GD library has gif support'
669  ));
670  } else {
671  $this->messageQueue->enqueue(new FlashMessage(
672  'GD is loaded, but calling imagecreatefromgif() fails. This must be fixed, TYPO3 CMS won\'t work well otherwise.',
673  'PHP GD library gif support broken',
674  ContextualFeedbackSeverity::ERROR
675  ));
676  }
677  } else {
678  $this->messageQueue->enqueue(new FlashMessage(
679  'GD must be compiled with gif support. This is essential for TYPO3 CMS to work properly.',
680  'PHP GD library gif support missing',
681  ContextualFeedbackSeverity::ERROR
682  ));
683  }
684  }
685 
689  protected function ‪checkGdLibJpgSupport()
690  {
691  if (function_exists('imagecreatefromjpeg')
692  && function_exists('imagejpeg')
693  && (imagetypes() & IMG_JPG)
694  ) {
695  $this->messageQueue->enqueue(new FlashMessage(
696  '',
697  'PHP GD library has jpg support'
698  ));
699  } else {
700  $this->messageQueue->enqueue(new FlashMessage(
701  'GD must be compiled with jpg support. This is essential for TYPO3 CMS to work properly.',
702  'PHP GD library jpg support missing',
703  ContextualFeedbackSeverity::ERROR
704  ));
705  }
706  }
707 
711  protected function ‪checkGdLibPngSupport()
712  {
713  if (function_exists('imagecreatefrompng')
714  && function_exists('imagepng')
715  && (imagetypes() & IMG_PNG)
716  ) {
717  // Do not use data:// wrapper to be independent of allow_url_fopen
718  $imageResource = @imagecreatefrompng(__DIR__ . '/../../Resources/Public/Images/TestInput/Test.png');
719  if ($this->‪checkImageResource($imageResource)) {
720  imagedestroy($imageResource);
721  $this->messageQueue->enqueue(new FlashMessage(
722  '',
723  'PHP GD library has png support'
724  ));
725  } else {
726  $this->messageQueue->enqueue(new FlashMessage(
727  'GD is compiled with png support, but calling imagecreatefrompng() fails.'
728  . ' Check your environment and fix it, png in GD lib is important'
729  . ' for TYPO3 CMS to work properly.',
730  'PHP GD library png support broken',
731  ContextualFeedbackSeverity::ERROR
732  ));
733  }
734  } else {
735  $this->messageQueue->enqueue(new FlashMessage(
736  'GD must be compiled with png support. This is essential for TYPO3 CMS to work properly',
737  'PHP GD library png support missing',
738  ContextualFeedbackSeverity::ERROR
739  ));
740  }
741  }
742 
746  protected function ‪checkGdLibFreeTypeSupport()
747  {
748  if (function_exists('imagettftext')) {
749  $this->messageQueue->enqueue(new FlashMessage(
750  'There is a difference between the font size setting which the GD'
751  . ' library should be supplied with. If installation is completed'
752  . ' a test in the install tool helps to find out the value you need.',
753  'PHP GD library has freetype font support'
754  ));
755  } else {
756  $this->messageQueue->enqueue(new FlashMessage(
757  'Some core functionality and extension rely on the GD'
758  . ' to render fonts on images. This support is missing'
759  . ' in your environment. Install it.',
760  'PHP GD library freetype support missing',
761  ContextualFeedbackSeverity::ERROR
762  ));
763  }
764  }
765 
776  protected function ‪isValidIp($ip)
777  {
778  return filter_var($ip, FILTER_VALIDATE_IP) !== false;
779  }
780 
786  protected function ‪isWindowsOs()
787  {
788  $windowsOs = false;
789  if (stripos(PHP_OS, 'darwin') === false && stripos(PHP_OS, 'win') !== false) {
790  $windowsOs = true;
791  }
792  return $windowsOs;
793  }
794 
801  protected function ‪getBytesFromSizeMeasurement($measurement)
802  {
803  $bytes = (float)$measurement;
804  if (stripos($measurement, 'G')) {
805  $bytes *= 1024 * 1024 * 1024;
806  } elseif (stripos($measurement, 'M')) {
807  $bytes *= 1024 * 1024;
808  } elseif (stripos($measurement, 'K')) {
809  $bytes *= 1024;
810  }
811  return (int)$bytes;
812  }
813 
814  private function ‪checkImageResource($imageResource): bool
815  {
816  return $imageResource instanceof \GdImage;
817  }
818 }
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:916
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkXdebugMaxNestingLevel
‪checkXdebugMaxNestingLevel()
Definition: Check.php:458
‪TYPO3\CMS\Install\SystemEnvironment\Check\$suggestedPhpExtensions
‪string[] $suggestedPhpExtensions
Definition: Check.php:71
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkMaxExecutionTime
‪checkMaxExecutionTime()
Definition: Check.php:311
‪TYPO3\CMS\Core\Information\Typo3Information
Definition: Typo3Information.php:28
‪TYPO3\CMS\Install\SystemEnvironment\Check\$requiredPhpExtensions
‪array $requiredPhpExtensions
Definition: Check.php:52
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkDisableFunctions
‪checkDisableFunctions()
Definition: Check.php:358
‪TYPO3\CMS\Install\SystemEnvironment\CheckInterface
Definition: CheckInterface.php:31
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkGdLibTrueColorSupport
‪checkGdLibTrueColorSupport()
Definition: Check.php:623
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkMaxInputVars
‪checkMaxInputVars()
Definition: Check.php:504
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkReflectionDocComment
‪checkReflectionDocComment()
Definition: Check.php:541
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkCurrentDirectoryIsInIncludePath
‪checkCurrentDirectoryIsInIncludePath()
Definition: Check.php:127
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkFileUploadEnabled
‪checkFileUploadEnabled()
Definition: Check.php:153
‪TYPO3\CMS\Install\SystemEnvironment\Check\getStatus
‪getStatus()
Definition: Check.php:89
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkPostUploadSizeIsHigherOrEqualMaximumFileUploadSize
‪checkPostUploadSizeIsHigherOrEqualMaximumFileUploadSize()
Definition: Check.php:177
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkGdLibGifSupport
‪checkGdLibGifSupport()
Definition: Check.php:653
‪TYPO3\CMS\Install\SystemEnvironment\Check\getBytesFromSizeMeasurement
‪int getBytesFromSizeMeasurement($measurement)
Definition: Check.php:798
‪TYPO3\CMS\Install\SystemEnvironment\Check\isWindowsOs
‪bool isWindowsOs()
Definition: Check.php:783
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Install\SystemEnvironment\Check\__construct
‪__construct()
Definition: Check.php:76
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkWindowsApacheThreadStackSize
‪checkWindowsApacheThreadStackSize()
Definition: Check.php:575
‪TYPO3\CMS\Install\SystemEnvironment
Definition: Check.php:18
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkGdLibFreeTypeSupport
‪checkGdLibFreeTypeSupport()
Definition: Check.php:743
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkGdLibPngSupport
‪checkGdLibPngSupport()
Definition: Check.php:708
‪TYPO3\CMS\Install\SystemEnvironment\Check\$messageQueue
‪FlashMessageQueue $messageQueue
Definition: Check.php:48
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkImageResource
‪checkImageResource($imageResource)
Definition: Check.php:811
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkPhpVersion
‪checkPhpVersion()
Definition: Check.php:255
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkGdLibJpgSupport
‪checkGdLibJpgSupport()
Definition: Check.php:686
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪TYPO3\CMS\Install\SystemEnvironment\Check
Definition: Check.php:45
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkPcreVersion
‪checkPcreVersion()
Definition: Check.php:277
‪TYPO3\CMS\Install\SystemEnvironment\Check\isValidIp
‪bool isValidIp($ip)
Definition: Check.php:773
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkOpenBaseDir
‪checkOpenBaseDir()
Definition: Check.php:434
‪TYPO3\CMS\Core\Information\Typo3Information\URL_OPCACHE
‪const URL_OPCACHE
Definition: Typo3Information.php:33
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkMemorySettings
‪checkMemorySettings()
Definition: Check.php:207
‪TYPO3\CMS\Install\SystemEnvironment\Check\getMessageQueue
‪getMessageQueue()
Definition: Check.php:81
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkPhpExtension
‪checkPhpExtension(string $extension, bool $required=true, string $purpose='')
Definition: Check.php:602
‪TYPO3\CMS\Core\Messaging\FlashMessageQueue
Definition: FlashMessageQueue.php:30
‪TYPO3\CMS\Install\SystemEnvironment\Check\checkDocRoot
‪checkDocRoot()
Definition: Check.php:409