/** * Removing system configuration by path * * Example: ./typo3cms configuration:removebypath DB,EXT/EXTCONF/realurl * * @param array $paths Path to system configuration that should be removed. Multiple paths can be specified separated by comma * @param bool $force If set, do not ask for confirmation */ public function removeByPathCommand(array $paths, $force = FALSE) { if (!$force) { do { $answer = strtolower($this->output->ask('Remove ' . implode(',', $paths) . ' from system configuration (TYPO3_CONF_VARS)? (y/N): ')); } while ($answer !== 'y' && $answer !== 'yes'); } $removed = $this->configurationManager->removeLocalConfigurationKeysByPath($paths); if (!$removed) { $this->outputLine('Paths seems invalid or empty. Nothing done!'); $this->sendAndExit(1); } $this->outputLine('Removed from system configuration'); }
/** * @test */ public function removeLocalConfigurationKeysByPathReturnsFalseIfSomethingInexistentIsRemoved() { $currentLocalConfiguration = array('notChanged' => 23); $this->createSubjectWithMockedMethods(array('getLocalConfiguration', 'writeLocalConfiguration')); $this->subject->expects($this->once())->method('getLocalConfiguration')->will($this->returnValue($currentLocalConfiguration)); $this->subject->expects($this->never())->method('writeLocalConfiguration'); $removeNonExisting = array('notPresent'); $this->assertFalse($this->subject->removeLocalConfigurationKeysByPath($removeNonExisting)); }
/** * 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(); } }
/** * $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] must be either * 'digest' or 'basic'. 'basic' is default in DefaultConfiguration, so the * setting can be removed from LocalConfiguration if it is not set to 'digest'. * * @return void */ protected function setProxyAuthScheme() { // Get current value from LocalConfiguration try { $currentValueInLocalConfiguration = $this->configurationManager->getLocalConfigurationValueByPath('HTTP/proxy_auth_scheme'); } catch (\RuntimeException $e) { // If an exception is thrown, the value is not set in LocalConfiguration, so we don't need to do anything return; } if ($currentValueInLocalConfiguration !== 'digest') { $this->configurationManager->removeLocalConfigurationKeysByPath(array('HTTP/proxy_auth_scheme')); $this->throwRedirectException(); } }
/** * Migrate the definition of the image processor from the configuration value * im_version_5 to the setting processor. * * @return void */ protected function migrateImageProcessorSetting() { $changedSettings = []; $settingsToRename = ['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(); } }