Exemple #1
0
 /**
  * Check if some opcode cache is loaded
  *
  * @return Status\StatusInterface
  */
 protected function checkSomePhpOpcodeCacheIsLoaded()
 {
     // Link to our wiki page, so we can update opcode cache issue information independent of TYPO3 CMS releases.
     $wikiLink = 'For more information take a look in our wiki ' . TYPO3_URL_WIKI_OPCODECACHE . '.';
     $opcodeCaches = \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::getAllActive();
     if (count($opcodeCaches) === 0) {
         // Set status to notice. It needs to be notice so email won't be triggered.
         $status = new Status\NoticeStatus();
         $status->setTitle('No PHP opcode cache loaded');
         $status->setMessage('PHP opcode caches hold a compiled version of executed PHP scripts in' . ' memory and do not require to recompile a script each time it is accessed.' . ' This can be a massive performance improvement and can reduce the load on a' . ' server in general. A parse time reduction by factor three for fully cached' . ' pages can be achieved easily if using an opcode cache.' . LF . $wikiLink);
     } else {
         $status = new Status\OkStatus();
         $message = '';
         foreach ($opcodeCaches as $opcodeCache => $properties) {
             $message .= 'Name: ' . $opcodeCache . ' Version: ' . $properties['version'];
             $message .= LF;
             if ($properties['error']) {
                 // Set status to error if not already set
                 if ($status->getSeverity() !== 'error') {
                     $status = new Status\ErrorStatus();
                 }
                 $message .= ' This opcode cache is marked as malfunctioning by the TYPO3 CMS Team.';
             } elseif ($properties['canInvalidate']) {
                 $message .= ' This opcode cache should work correctly and has good performance.';
             } else {
                 // Set status to notice if not already error set. It needs to be notice so email won't be triggered.
                 if ($status->getSeverity() !== 'error' || $status->getSeverity() !== 'warning') {
                     $status = new Status\NoticeStatus();
                 }
                 $message .= ' This opcode cache may work correctly but has medium performance.';
             }
             $message .= LF;
         }
         $message .= $wikiLink;
         // Set title of status depending on serverity
         switch ($status->getSeverity()) {
             case 'error':
                 $status->setTitle('A possibly malfunctioning PHP opcode cache is loaded');
                 break;
             case 'warning':
                 $status->setTitle('A PHP opcode cache is loaded which may cause problems');
                 break;
             case 'ok':
             default:
                 $status->setTitle('A PHP opcode cache is loaded');
                 break;
         }
         $status->setMessage($message);
     }
     return $status;
 }