/**
  * Detail configuration of Image Magick and Graphics Magick settings
  * depending on main values.
  *
  * "Configuration presets" in install tool is not type safe, so value
  * comparisons here are not type safe too, to not trigger changes to
  * LocalConfiguration again.
  *
  * @return void
  */
 protected function setImageMagickDetailSettings()
 {
     $changedValues = array();
     try {
         $currentIm5Value = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_version_5');
     } catch (\RuntimeException $e) {
         $currentIm5Value = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/im_version_5');
     }
     try {
         $currentImMaskValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_mask_temp_ext_gif');
     } catch (\RuntimeException $e) {
         $currentImMaskValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/im_mask_temp_ext_gif');
     }
     try {
         $currentIm5EffectsValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_v5effects');
     } catch (\RuntimeException $e) {
         $currentIm5EffectsValue = $this->configurationManager->getDefaultConfigurationValueByPath('GFX/im_v5effects');
     }
     if ((string) $currentIm5Value !== '') {
         if ($currentImMaskValue != 1) {
             $changedValues['GFX/im_mask_temp_ext_gif'] = 1;
         }
         if ($currentIm5Value === 'gm') {
             if ($currentIm5EffectsValue != -1) {
                 $changedValues['GFX/im_v5effects'] = -1;
             }
         }
     }
     if (!empty($changedValues)) {
         $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($changedValues);
         $this->throwRedirectException();
     }
 }
 /**
  * Constructor of the language repository
  */
 public function __construct()
 {
     try {
         $globalSettings = \TYPO3\CMS\Core\Configuration\ConfigurationManager::getLocalConfigurationValueByPath($this->configurationPath);
         $this->selectedLanguages = (array) $globalSettings['availableLanguages'];
     } catch (\Exception $e) {
         \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath($this->configurationPath, array('availableLanguages' => array()));
     }
 }
 /**
  * Migrate old Install Tool Wizard "done"-settings to new class names
  * this happens usually when an existing 6.0/6.1 has called the TceformsUpdateWizard wizard
  * and has written Tx_Install_Updates_File_TceformsUpdateWizard in TYPO3's LocalConfiguration.php
  *
  * @return void
  */
 protected function migrateOldInstallWizardDoneSettingsToNewClassNames()
 {
     $classNamesToConvert = array();
     $localConfiguration = $this->configurationManager->getLocalConfiguration();
     // check for wizards that have been run already and don't start with TYPO3...
     if (isset($localConfiguration['INSTALL']['wizardDone']) && is_array($localConfiguration['INSTALL']['wizardDone'])) {
         $classNames = array_keys($localConfiguration['INSTALL']['wizardDone']);
         foreach ($classNames as $className) {
             if (!GeneralUtility::isFirstPartOfStr($className, 'TYPO3')) {
                 $classNamesToConvert[] = $className;
             }
         }
     }
     if (!count($classNamesToConvert)) {
         return;
     }
     $migratedClassesMapping = array('Tx_Install_Updates_File_TceformsUpdateWizard' => 'TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard');
     $migratedSettings = array();
     $settingsToRemove = array();
     foreach ($classNamesToConvert as $oldClassName) {
         if (isset($migratedClassesMapping[$oldClassName])) {
             $newClassName = $migratedClassesMapping[$oldClassName];
         } else {
             continue;
         }
         $oldValue = NULL;
         $newValue = NULL;
         try {
             $oldValue = $this->configurationManager->getLocalConfigurationValueByPath('INSTALL/wizardDone/' . $oldClassName);
         } catch (\RuntimeException $e) {
             // The old configuration does not exist
             continue;
         }
         try {
             $newValue = $this->configurationManager->getLocalConfigurationValueByPath('INSTALL/wizardDone/' . $newClassName);
         } catch (\RuntimeException $e) {
             // The new configuration does not exist yet
         }
         if ($newValue === NULL) {
             // Migrate the old configuration to the new one
             $migratedSettings['INSTALL/wizardDone/' . $newClassName] = $oldValue;
         }
         $settingsToRemove[] = 'INSTALL/wizardDone/' . $oldClassName;
     }
     if (count($migratedSettings)) {
         $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($migratedSettings);
     }
     $this->configurationManager->removeLocalConfigurationKeysByPath($settingsToRemove);
     if (count($migratedSettings) || count($settingsToRemove)) {
         $this->throwRedirectException();
     }
 }
Example #4
0
 /**
  * Migrate the configuration setting BE/lockSSL to boolean if set in the LocalConfiguration.php file
  *
  * @return void
  */
 protected function migrateLockSslSetting()
 {
     try {
         $currentOption = $this->configurationManager->getLocalConfigurationValueByPath('BE/lockSSL');
         // check if the current option is an integer/string and if it is active
         if (!is_bool($currentOption) && (int) $currentOption > 0) {
             $this->configurationManager->setLocalConfigurationValueByPath('BE/lockSSL', true);
             $this->throwRedirectException();
         }
     } catch (\RuntimeException $e) {
         // no change inside the LocalConfiguration.php found, so nothing needs to be modified
     }
 }
 /**
  * Write the current configuration to localconf.php
  * This is needed for any sites that were relying on the former default
  * values which are going to change in TYPO3 4.5.
  *
  * @param 	array		&$dbQueries: queries done in this update
  * @param 	mixed		&$customMessages: custom messages
  * @return 	boolean		whether the updated was made or not
  */
 public function performUpdate(array &$dbQueries, &$customMessages)
 {
     // Update "setDBinit" setting
     $result1 = FALSE;
     if (\TYPO3\CMS\Core\Configuration\ConfigurationManager::getLocalConfigurationValueByPath('SYS/setDBinit') === '-1') {
         $result1 = \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('SYS/setDBinit', '');
     }
     // Update the "forceCharset" setting
     $result2 = FALSE;
     if (\TYPO3\CMS\Core\Configuration\ConfigurationManager::getLocalConfigurationValueByPath('BE/forceCharset') !== '') {
         $result2 = \TYPO3\CMS\Core\Configuration\ConfigurationManager::setLocalConfigurationValueByPath('BE/forceCharset', '');
     }
     if ($result1 && $result2) {
         $customMessages[] = 'The configuration was successfully updated.';
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * Migrate the definition of the image processor from the configuration value
  * im_version_5 to the setting processor.
  *
  * @return void
  */
 protected function migrateImageProcessorSetting()
 {
     $changedSettings = array();
     $settingsToRename = array('GFX/im' => 'GFX/processor_enabled', 'GFX/im_version_5' => 'GFX/processor', 'GFX/im_v5effects' => 'GFX/processor_effects', 'GFX/im_path' => 'GFX/processor_path', 'GFX/im_path_lzw' => 'GFX/processor_path_lzw', 'GFX/im_mask_temp_ext_gif' => 'GFX/processor_allowTemporaryMasksAsPng', 'GFX/im_noScaleUp' => 'GFX/processor_allowUpscaling', 'GFX/im_noFramePrepended' => 'GFX/processor_allowFrameSelection', 'GFX/im_stripProfileCommand' => 'GFX/processor_stripColorProfileCommand', 'GFX/im_useStripProfileByDefault' => 'GFX/processor_stripColorProfileByDefault', 'GFX/colorspace' => 'GFX/processor_colorspace');
     foreach ($settingsToRename as $oldPath => $newPath) {
         try {
             $value = $this->configurationManager->getLocalConfigurationValueByPath($oldPath);
             $this->configurationManager->setLocalConfigurationValueByPath($newPath, $value);
             $changedSettings[$oldPath] = true;
         } catch (\RuntimeException $e) {
             // If an exception is thrown, the value is not set in LocalConfiguration
             $changedSettings[$oldPath] = false;
         }
     }
     if (!empty($changedSettings['GFX/im_version_5'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_version_5');
         $newProcessorValue = $currentProcessorValue === 'gm' ? 'GraphicsMagick' : 'ImageMagick';
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor', $newProcessorValue);
     }
     if (!empty($changedSettings['GFX/im_noScaleUp'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_noScaleUp');
         $newProcessorValue = !$currentProcessorValue;
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor_allowUpscaling', $newProcessorValue);
     }
     if (!empty($changedSettings['GFX/im_noFramePrepended'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_noFramePrepended');
         $newProcessorValue = !$currentProcessorValue;
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor_allowFrameSelection', $newProcessorValue);
     }
     if (!empty($changedSettings['GFX/im_mask_temp_ext_gif'])) {
         $currentProcessorValue = $this->configurationManager->getLocalConfigurationValueByPath('GFX/im_mask_temp_ext_gif');
         $newProcessorValue = !$currentProcessorValue;
         $this->configurationManager->setLocalConfigurationValueByPath('GFX/processor_allowTemporaryMasksAsPng', $newProcessorValue);
     }
     if (!empty(array_filter($changedSettings))) {
         $this->configurationManager->removeLocalConfigurationKeysByPath(array_keys($changedSettings));
         $this->throwRedirectException();
     }
 }
 /**
  * @test
  */
 public function getLocalConfigurationValueByPathReturnsCorrectValue()
 {
     $this->createSubjectWithMockedMethods(array('getLocalConfiguration'));
     $this->subject->expects($this->once())->method('getLocalConfiguration')->will($this->returnValue(array('path' => 'value')));
     $this->assertSame('value', $this->subject->getLocalConfigurationValueByPath('path'));
 }
 /**
  * Unloads given extension
  *
  * Warning: This method only works if the ugrade wizard to transform
  * localconf.php to LocalConfiguration.php was already run
  *
  * @param string $extensionKey Extension key to remove
  * @return void
  * @throws RuntimeException
  */
 public static function unloadExtension($extensionKey)
 {
     if (!static::isLoaded($extensionKey)) {
         throw new \RuntimeException('Extension not loaded', 1342345487);
     }
     if (in_array($extensionKey, static::getRequiredExtensionListArray())) {
         throw new \RuntimeException('Can not unload required extension', 1342348167);
     }
     $extList = \TYPO3\CMS\Core\Configuration\ConfigurationManager::getLocalConfigurationValueByPath('EXT/extListArray');
     $extList = array_diff($extList, array($extensionKey));
     static::writeNewExtensionList($extList);
 }