Esempio n. 1
0
 /**
  * Reload Cache files and Typo3LoadedExtensions
  *
  * @return void
  */
 public function reloadCaches()
 {
     \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive();
     // Reload class aliases defined in Migrations/Code/ClassAliasMap.php
     \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader')->setPackages($this->packageManager->getActivePackages());
     \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtLocalconf(FALSE);
     \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadExtensionTables(FALSE);
 }
Esempio n. 2
0
 /**
  * Saves the current content of $this->packageStatesConfiguration to the
  * PackageStates.php file.
  *
  * @return void
  */
 protected function sortAndSavePackageStates()
 {
     parent::sortAndSavePackageStates();
     $this->initializeCompatibilityLoadedExtArray();
     \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive($this->packageStatesPathAndFilename);
 }
Esempio n. 3
0
 /**
  * Clears the opcode cache. This just wraps the static call for testing purposes.
  *
  * @param string|NULL $fileAbsPath The file as absolute path to be cleared
  *                                 or NULL to clear completely.
  *
  * @return void
  */
 protected function clearAllActiveOpcodeCacheWrapper($fileAbsPath)
 {
     \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive($fileAbsPath);
 }
Esempio n. 4
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;
 }
 /**
  * Write local configuration array to typo3conf/LocalConfiguration.php
  *
  * @param array $configuration The local configuration to be written
  * @throws \RuntimeException
  * @return boolean TRUE on success
  * @access private
  */
 public function writeLocalConfiguration(array $configuration)
 {
     $localConfigurationFile = $this->getLocalConfigurationFileLocation();
     if (!$this->canWriteConfiguration()) {
         throw new \RuntimeException($localConfigurationFile . ' is not writable.', 1346323822);
     }
     $configuration = Utility\ArrayUtility::sortByKeyRecursive($configuration);
     $result = Utility\GeneralUtility::writeFile($localConfigurationFile, '<?php' . LF . 'return ' . Utility\ArrayUtility::arrayExport(Utility\ArrayUtility::renumberKeysToAvoidLeapsIfKeysAreAllNumeric($configuration)) . ';' . LF . '?>', TRUE);
     Utility\OpcodeCacheUtility::clearAllActive($localConfigurationFile);
     return $result;
 }
 /**
  * Activate a core version
  *
  * @param string $version A version to activate
  * @return boolean TRUE on success
  */
 public function activateVersion($version)
 {
     $newCoreLocation = @realPath($this->symlinkToCoreFiles . '/../') . '/typo3_src-' . $version;
     $messages = array();
     $success = TRUE;
     if (!is_dir($newCoreLocation)) {
         $success = FALSE;
         /** @var $message StatusInterface */
         $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
         $message->setTitle('New TYPO3 CMS core not found');
         $messages[] = $message;
     } elseif (!is_link($this->symlinkToCoreFiles)) {
         $success = FALSE;
         /** @var $message StatusInterface */
         $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
         $message->setTitle('TYPO3 CMS core source directory (typo3_src) is not a link');
         $messages[] = $message;
     } else {
         $isCurrentCoreSymlinkAbsolute = PathUtility::isAbsolutePath(readlink($this->symlinkToCoreFiles));
         $unlinkResult = unlink($this->symlinkToCoreFiles);
         if (!$unlinkResult) {
             $success = FALSE;
             /** @var $message StatusInterface */
             $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
             $message->setTitle('Removing old symlink failed');
             $messages[] = $message;
         } else {
             if (!$isCurrentCoreSymlinkAbsolute) {
                 $newCoreLocation = $this->getRelativePath($newCoreLocation);
             }
             $symlinkResult = symlink($newCoreLocation, $this->symlinkToCoreFiles);
             if ($symlinkResult) {
                 OpcodeCacheUtility::clearAllActive();
             } else {
                 $success = FALSE;
                 /** @var $message StatusInterface */
                 $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
                 $message->setTitle('Linking new TYPO3 CMS core failed');
                 $messages[] = $message;
             }
         }
     }
     $this->messages = $messages;
     return $success;
 }
 /**
  * Use this to clear the opcode cache.
  *
  * @param string|NULL $fileAbsPath
  * @return void
  */
 protected function clearAllActiveOpcodeCacheWrapper($fileAbsPath)
 {
     if (version_compare(TYPO3_version, '7.4.0', '>=')) {
         /** @var \TYPO3\CMS\Core\Service\OpcodeCacheService $opcodeCacheService */
         $opcodeCacheService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Service\\OpcodeCacheService');
         $opcodeCacheService->clearAllActive($fileAbsPath);
     } else {
         \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive($fileAbsPath);
     }
 }
Esempio n. 8
0
 /**
  * Saves data in a cache file.
  *
  * @param string $entryIdentifier An identifier for this specific cache entry
  * @param string $data The data to be stored
  * @param array $tags Tags to associate with this cache entry
  * @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
  * @return void
  * @throws \RuntimeException
  * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
  * @throws \TYPO3\CMS\Core\Cache\Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
  * @throws \InvalidArgumentException
  * @api
  */
 public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL)
 {
     if (!is_string($data)) {
         throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1204481674);
     }
     if ($entryIdentifier !== basename($entryIdentifier)) {
         throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032);
     }
     if ($entryIdentifier === '') {
         throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1298114280);
     }
     if ($this->frozen === TRUE) {
         throw new \RuntimeException(sprintf('Cannot add or modify cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344192);
     }
     $this->remove($entryIdentifier);
     $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . uniqid() . '.temp';
     $lifetime = $lifetime === NULL ? $this->defaultLifetime : $lifetime;
     $expiryTime = $lifetime === 0 ? 0 : $GLOBALS['EXEC_TIME'] + $lifetime;
     $metaData = str_pad($expiryTime, self::EXPIRYTIME_LENGTH) . implode(' ', $tags) . str_pad(strlen($data), self::DATASIZE_DIGITS);
     $result = file_put_contents($temporaryCacheEntryPathAndFilename, $data . $metaData);
     \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename);
     if ($result === FALSE) {
         throw new \TYPO3\CMS\Core\Cache\Exception('The temporary cache file "' . $temporaryCacheEntryPathAndFilename . '" could not be written.', 1204026251);
     }
     $i = 0;
     $cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
     while (($result = rename($temporaryCacheEntryPathAndFilename, $cacheEntryPathAndFilename)) === FALSE && $i < 5) {
         $i++;
     }
     if ($result === FALSE) {
         throw new \TYPO3\CMS\Core\Cache\Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1222361632);
     }
     if ($this->cacheEntryFileExtension === '.php') {
         \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive($cacheEntryPathAndFilename);
     }
 }
Esempio n. 9
0
 /**
  * Saves data in a cache file.
  *
  * @param string $entryIdentifier An identifier for this specific cache entry
  * @param string $data The data to be stored
  * @param array $tags Tags to associate with this cache entry
  * @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
  * @return void
  * @throws \TYPO3\CMS\Core\Cache\Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
  * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if the data to bes stored is not a string.
  * @throws \InvalidArgumentException
  * @api
  */
 public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL)
 {
     if (!is_string($data)) {
         throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1334756734);
     }
     if ($entryIdentifier !== basename($entryIdentifier)) {
         throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735);
     }
     if ($entryIdentifier === '') {
         throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1334756736);
     }
     $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . uniqid() . '.temp';
     $result = file_put_contents($temporaryCacheEntryPathAndFilename, $data);
     \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename);
     if ($result === FALSE) {
         throw new \TYPO3\CMS\Core\Cache\Exception('The temporary cache file "' . $temporaryCacheEntryPathAndFilename . '" could not be written.', 1334756737);
     }
     $cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
     rename($temporaryCacheEntryPathAndFilename, $cacheEntryPathAndFilename);
     if ($this->cacheEntryFileExtension === '.php') {
         \TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive($cacheEntryPathAndFilename);
     }
 }
Esempio n. 10
0
 /**
  * Clear PHP opcode cache
  *
  * @return \TYPO3\CMS\Install\Status\StatusInterface
  */
 protected function clearOpcodeCache()
 {
     /** @var \TYPO3\CMS\Install\Service\ClearCacheService $clearCacheService */
     OpcodeCacheUtility::clearAllActive();
     $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\OkStatus');
     $message->setTitle('Successfully cleared all available opcode caches');
     return $message;
 }