39 $configurationManager = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
43 $result[] = $this->executeLoadDbalExtension();
45 $result[] = $this->executeUnloadDbalExtension();
51 $driverConfig = array(
52 'useNameQuote' => TRUE,
57 $driverConfig = array(
58 'driverOptions' => array(
72 if (isset($driverConfig)) {
73 $config[
'_DEFAULT'][
'config'] = array_merge($config[
'_DEFAULT'][
'config'], $driverConfig);
75 $configurationManager->setLocalConfigurationValueByPath(
'EXTCONF/dbal/handlerCfg', $config);
77 $localConfigurationPathValuePairs = array();
80 $config = $configurationManager->getConfigurationValueByPath(
'EXTCONF/dbal/handlerCfg');
81 $driver = $config[
'_DEFAULT'][
'config'][
'driver'];
83 $config[
'_DEFAULT'][
'config'][
'driverOptions'][
'connectSID'] = (
$postValues[
'type'] ===
'sid');
84 $localConfigurationPathValuePairs[
'EXTCONF/dbal/handlerCfg'] = $config;
90 if (strlen($value) <= 50) {
91 $localConfigurationPathValuePairs[
'DB/username'] = $value;
94 $errorStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
95 $errorStatus->setTitle(
'Database username not valid');
96 $errorStatus->setMessage(
'Given username must be shorter than fifty characters.');
103 if (strlen($value) <= 50) {
104 $localConfigurationPathValuePairs[
'DB/password'] = $value;
107 $errorStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
108 $errorStatus->setTitle(
'Database password not valid');
109 $errorStatus->setMessage(
'Given password must be shorter than fifty characters.');
116 if (preg_match(
'/^[a-zA-Z0-9_\\.-]+(:.+)?$/', $value) && strlen($value) <= 50) {
117 $localConfigurationPathValuePairs[
'DB/host'] = $value;
120 $errorStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
121 $errorStatus->setTitle(
'Database host not valid');
122 $errorStatus->setMessage(
'Given host is not alphanumeric (a-z, A-Z, 0-9 or _-.:) or longer than fifty characters.');
129 if (preg_match(
'/^[0-9]+(:.+)?$/', $value) && $value > 0 && $value <= 65535) {
130 $localConfigurationPathValuePairs[
'DB/port'] = (int)$value;
133 $errorStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
134 $errorStatus->setTitle(
'Database port not valid');
135 $errorStatus->setMessage(
'Given port is not numeric or within range 1 to 65535.');
142 $localConfigurationPathValuePairs[
'DB/socket'] =
$postValues[
'socket'];
145 $errorStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
146 $errorStatus->setTitle(
'Socket does not exist');
147 $errorStatus->setMessage(
'Given socket location does not exist on server.');
154 if (strlen($value) <= 50) {
155 $localConfigurationPathValuePairs[
'DB/database'] = $value;
158 $errorStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
159 $errorStatus->setTitle(
'Database name not valid');
160 $errorStatus->setMessage(
'Given database name must be shorter than fifty characters.');
165 if (!empty($localConfigurationPathValuePairs)) {
166 $configurationManager->setLocalConfigurationValuesByPathValuePairs($localConfigurationPathValuePairs);
172 ->populateLocalConfiguration()
173 ->disableCoreAndClassesCache();
178 if (!$this->isConnectSuccessful()) {
180 $errorStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
181 $errorStatus->setTitle(
'Database connect not successful');
182 $errorStatus->setMessage(
'Connecting to the database with given settings failed. Please check.');
202 $this->useDefaultValuesForNotConfiguredOptions();
203 throw new \TYPO3\CMS\Install\Controller\Exception\RedirectException(
204 'Wrote default settings to LocalConfiguration.php, redirect needed',
219 ->assign(
'isDbalEnabled', $isDbalEnabled)
224 ->assign(
'database',
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'database'] ?:
'')
225 ->assign(
'socket',
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'socket'] ?:
'');
227 if ($isDbalEnabled) {
233 ->assign(
'renderConnectDetailsUsername', TRUE)
234 ->assign(
'renderConnectDetailsPassword', TRUE)
235 ->assign(
'renderConnectDetailsHost', TRUE)
236 ->assign(
'renderConnectDetailsPort', TRUE)
237 ->assign(
'renderConnectDetailsSocket', TRUE);
241 return $this->view->render();
251 if (!$configuredPort) {
272 $port = $configuredPort;
282 protected function isConnectSuccessful() {
284 $databaseConnection = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
289 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'database'])) {
290 $databaseConnection->setDatabaseName(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'database']);
300 $databaseConnection->initialize();
302 return (
bool)@$databaseConnection->sql_pconnect();
313 $hostConfigured = TRUE;
314 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'host'])) {
315 $hostConfigured = FALSE;
318 !isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'port'])
319 && !isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'socket'])
321 $hostConfigured = FALSE;
323 return $hostConfigured;
336 if (!isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'username'])) {
337 $configurationComplete = FALSE;
339 if (!isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'password'])) {
340 $configurationComplete = FALSE;
342 return $configurationComplete;
361 protected function useDefaultValuesForNotConfiguredOptions() {
362 $localConfigurationPathValuePairs = array();
368 if ($localConfigurationPathValuePairs[
'DB/host'] ===
'localhost' 370 || strlen($localConfigurationPathValuePairs[
'DB/host']) === 0
373 $localConfigurationPathValuePairs[
'DB/host'] =
'localhost';
377 $localConfigurationPathValuePairs[
'DB/host'] =
'127.0.0.1';
382 if (!isset($localConfigurationPathValuePairs[
'DB/socket'])) {
387 $localConfigurationPathValuePairs[
'DB/port'] = $port;
394 $configurationManager = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
395 $configurationManager->setLocalConfigurationValuesByPathValuePairs($localConfigurationPathValuePairs);
408 if (!strlen($socket) > 0) {
410 $defaultSocket = ini_get(
'mysqli.default_socket');
411 if (strlen($defaultSocket) > 0) {
412 $socket = $defaultSocket;
415 if (strlen($socket) > 0) {
416 $socketOpenResult = @fsockopen(
'unix://' . $socket);
417 if ($socketOpenResult) {
418 fclose($socketOpenResult);
439 ->assign(
'renderConnectDetailsUsername', TRUE)
440 ->assign(
'renderConnectDetailsPassword', TRUE)
441 ->assign(
'renderConnectDetailsHost', TRUE)
442 ->assign(
'renderConnectDetailsPort', TRUE)
443 ->assign(
'renderConnectDetailsDatabase', TRUE);
447 ->assign(
'renderConnectDetailsUsername', TRUE)
448 ->assign(
'renderConnectDetailsPassword', TRUE)
449 ->assign(
'renderConnectDetailsHost', TRUE)
450 ->assign(
'renderConnectDetailsPort', TRUE)
451 ->assign(
'renderConnectDetailsDatabase', TRUE)
452 ->assign(
'renderConnectDetailsOracleSidConnect', TRUE);
453 $type = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'dbal'][
'handlerCfg'][
'_DEFAULT'][
'config'][
'driverOptions'][
'connectSID'])
454 ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'dbal'][
'handlerCfg'][
'_DEFAULT'][
'config'][
'driverOptions'][
'connectSID']
456 if ($type === TRUE) {
457 $this->view->assign(
'oracleSidSelected', TRUE);
470 $availableDrivers = array();
472 foreach ($supportedDrivers as $abstractionLayer => $drivers) {
473 foreach ($drivers as
$driver => $info) {
474 if (isset($info[
'combine']) && $info[
'combine'] ===
'OR') {
475 $isAvailable = FALSE;
480 foreach ($info[
'extensions'] as $extension) {
481 if (isset($info[
'combine']) && $info[
'combine'] ===
'OR') {
482 $isAvailable |= extension_loaded($extension);
484 $isAvailable &= extension_loaded($extension);
488 if (!isset($availableDrivers[$abstractionLayer])) {
489 $availableDrivers[$abstractionLayer] = array();
491 $availableDrivers[$abstractionLayer][
$driver] = array();
492 $availableDrivers[$abstractionLayer][
$driver][
'driver'] =
$driver;
493 $availableDrivers[$abstractionLayer][
$driver][
'label'] = $info[
'label'];
494 $availableDrivers[$abstractionLayer][
$driver][
'selected'] = FALSE;
495 if ($selectedDbalDriver ===
$driver) {
496 $availableDrivers[$abstractionLayer][
$driver][
'selected'] = TRUE;
501 return $availableDrivers;
511 $supportedDrivers = array(
514 'label' =>
'Microsoft SQL Server',
515 'extensions' => array(
'mssql')
518 'label' =>
'Oracle OCI8',
519 'extensions' => array(
'oci8')
522 'label' =>
'PostgreSQL',
523 'extensions' => array(
'pgsql')
527 'odbc_mssql' => array(
528 'label' =>
'Microsoft SQL Server',
529 'extensions' => array(
'odbc',
'mssql')
533 return $supportedDrivers;
542 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'dbal'][
'handlerCfg'][
'_DEFAULT'][
'config'][
'driver'])) {
543 return $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'dbal'][
'handlerCfg'][
'_DEFAULT'][
'config'][
'driver'];
553 protected function executeLoadDbalExtension() {
561 $warningStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\WarningStatus');
562 $warningStatus->setTitle(
'Loaded database abstraction layer');
563 return $warningStatus;
571 protected function executeUnloadDbalExtension() {
580 $warningStatus = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\WarningStatus');
581 $warningStatus->setTitle(
'Removed database abstraction layer');
582 return $warningStatus;
591 $username = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'username']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'username'] :
'';
601 $password = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'password']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'password'] :
'';
611 $host = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'host']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'host'] :
'';
612 $port = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'port']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'port'] :
'';
613 if (strlen($port) < 1 && substr_count(
$host,
':') === 1) {
625 $host = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'host']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'host'] :
'';
626 $port = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'port']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'port'] :
'';
627 if (strlen($port) === 0 && substr_count(
$host,
':') === 1) {
628 $hostPortArray = explode(
':',
$host);
629 $port = $hostPortArray[1];
640 $socket = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'socket']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'socket'] :
'';
static isFirstPartOfStr($str, $partStr)
static extPath($key, $script='')
getSupportedDbalDrivers()
isConnectionWithUnixDomainSocketPossible()
static makeInstance($className)
static cmpIP($baseIP, $list)
getConfiguredOrDefaultPort()
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
setDbalInputFieldsToRender()
static isLoaded($key, $exitOnError=FALSE)
getAvailableDbalDrivers()
isConfigurationComplete()
static unloadExtension($extensionKey)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static loadExtension($extensionKey)