[BUGFIX] Install Tool fatal with Oracle database
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / DatabaseConnect.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Step;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Install\Controller\Action;
28
29 /**
30 * Database connect step:
31 * - Needs execution if database credentials are not set or fail to connect
32 * - Renders fields for database connection fields
33 * - Sets database credentials in LocalConfiguration
34 * - Loads / unloads ext:dbal and ext:adodb if requested
35 */
36 class DatabaseConnect extends Action\AbstractAction implements StepInterface {
37
38 /**
39 * Execute database step:
40 * - Load / unload dbal & adodb
41 * - Set database connect credentials in LocalConfiguration
42 *
43 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
44 */
45 public function execute() {
46 $result = array();
47
48 /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
49 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
50
51 $postValues = $this->postValues['values'];
52 if (isset($postValues['loadDbal'])) {
53 $result[] = $this->executeLoadDbalExtension();
54 } elseif ($postValues['unloadDbal']) {
55 $result[] = $this->executeUnloadDbalExtension();
56 } elseif ($postValues['setDbalDriver']) {
57 $driver = $postValues['setDbalDriver'];
58 switch ($driver) {
59 case 'mssql':
60 case 'odbc_mssql':
61 $driverConfig = array(
62 'useNameQuote' => TRUE,
63 'quoteClob' => FALSE,
64 );
65 break;
66 case 'oci8':
67 $driverConfig = array(
68 'driverOptions' => array(
69 'connectSID' => '',
70 ),
71 );
72 break;
73 }
74 $config = array(
75 '_DEFAULT' => array(
76 'type' => 'adodb',
77 'config' => array(
78 'driver' => $driver,
79 )
80 )
81 );
82 if (isset($driverConfig)) {
83 $config['_DEFAULT']['config'] = array_merge($config['_DEFAULT']['config'], $driverConfig);
84 }
85 $configurationManager->setLocalConfigurationValueByPath('EXTCONF/dbal/handlerCfg', $config);
86 } else {
87 $localConfigurationPathValuePairs = array();
88
89 if ($this->isDbalEnabled()) {
90 $config = $configurationManager->getConfigurationValueByPath('EXTCONF/dbal/handlerCfg');
91 $driver = $config['_DEFAULT']['config']['driver'];
92 if ($driver === 'oci8') {
93 $config['_DEFAULT']['config']['driverOptions']['connectSID'] = ($postValues['type'] === 'sid');
94 $localConfigurationPathValuePairs['EXTCONF/dbal/handlerCfg'] = $config;
95 }
96 }
97
98 if (isset($postValues['username'])) {
99 $value = $postValues['username'];
100 if (strlen($value) <= 50) {
101 $localConfigurationPathValuePairs['DB/username'] = $value;
102 } else {
103 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
104 $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
105 $errorStatus->setTitle('Database username not valid');
106 $errorStatus->setMessage('Given username must be shorter than fifty characters.');
107 $result[] = $errorStatus;
108 }
109 }
110
111 if (isset($postValues['password'])) {
112 $value = $postValues['password'];
113 if (strlen($value) <= 50) {
114 $localConfigurationPathValuePairs['DB/password'] = $value;
115 } else {
116 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
117 $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
118 $errorStatus->setTitle('Database password not valid');
119 $errorStatus->setMessage('Given password must be shorter than fifty characters.');
120 $result[] = $errorStatus;
121 }
122 }
123
124 if (isset($postValues['host'])) {
125 $value = $postValues['host'];
126 if (preg_match('/^[a-zA-Z0-9_\\.-]+(:.+)?$/', $value) && strlen($value) <= 50) {
127 $localConfigurationPathValuePairs['DB/host'] = $value;
128 } else {
129 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
130 $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
131 $errorStatus->setTitle('Database host not valid');
132 $errorStatus->setMessage('Given host is not alphanumeric (a-z, A-Z, 0-9 or _-.:) or longer than fifty characters.');
133 $result[] = $errorStatus;
134 }
135 }
136
137 if (isset($postValues['port']) && $postValues['host'] !== 'localhost') {
138 $value = $postValues['port'];
139 if (preg_match('/^[0-9]+(:.+)?$/', $value) && $value > 0 && $value <= 65535) {
140 $localConfigurationPathValuePairs['DB/port'] = (int)$value;
141 } else {
142 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
143 $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
144 $errorStatus->setTitle('Database port not valid');
145 $errorStatus->setMessage('Given port is not numeric or within range 1 to 65535.');
146 $result[] = $errorStatus;
147 }
148 }
149
150 if (isset($postValues['socket']) && $postValues['socket'] !== '') {
151 if (@file_exists($postValues['socket'])) {
152 $localConfigurationPathValuePairs['DB/socket'] = $postValues['socket'];
153 } else {
154 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
155 $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
156 $errorStatus->setTitle('Socket does not exist');
157 $errorStatus->setMessage('Given socket location does not exist on server.');
158 $result[] = $errorStatus;
159 }
160 }
161
162 if (isset($postValues['database'])) {
163 $value = $postValues['database'];
164 if (strlen($value) <= 50) {
165 $localConfigurationPathValuePairs['DB/database'] = $value;
166 } else {
167 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
168 $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
169 $errorStatus->setTitle('Database name not valid');
170 $errorStatus->setMessage('Given database name must be shorter than fifty characters.');
171 $result[] = $errorStatus;
172 }
173 }
174
175 if (!empty($localConfigurationPathValuePairs)) {
176 $configurationManager->setLocalConfigurationValuesByPathValuePairs($localConfigurationPathValuePairs);
177
178 // After setting new credentials, test again and create an error message if connect is not successful
179 // @TODO: This could be simplified, if isConnectSuccessful could be released from TYPO3_CONF_VARS
180 // and feeded with connect values directly in order to obsolete the bootstrap reload.
181 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
182 ->populateLocalConfiguration()
183 ->setCoreCacheToNullBackend();
184 if ($this->isDbalEnabled()) {
185 require(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('dbal') . 'ext_localconf.php');
186 $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
187 }
188 if (!$this->isConnectSuccessful()) {
189 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
190 $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
191 $errorStatus->setTitle('Database connect not successful');
192 $errorStatus->setMessage('Connecting the database with given settings failed. Please check.');
193 $result[] = $errorStatus;
194 }
195 }
196 }
197
198 return $result;
199 }
200
201 /**
202 * Step needs to be executed if database connection is not successful.
203 *
204 * @throws \TYPO3\CMS\Install\Controller\Exception\RedirectException
205 * @return boolean
206 */
207 public function needsExecution() {
208 if ($this->isConnectSuccessful() && $this->isConfigurationComplete()) {
209 return FALSE;
210 }
211 if (!$this->isHostConfigured() && !$this->isDbalEnabled()) {
212 $this->useDefaultValuesForNotConfiguredOptions();
213 throw new \TYPO3\CMS\Install\Controller\Exception\RedirectException(
214 'Wrote default settings to LocalConfiguration.php, redirect needed',
215 1377611168
216 );
217 }
218 return TRUE;
219 }
220
221 /**
222 * Render this step
223 *
224 * @return string
225 */
226 public function handle() {
227 $this->initializeHandle();
228
229 $isDbalEnabled = $this->isDbalEnabled();
230 $this->view
231 ->assign('isDbalEnabled', $isDbalEnabled)
232 ->assign('username', $this->getConfiguredUsername())
233 ->assign('password', $this->getConfiguredPassword())
234 ->assign('host', $this->getConfiguredHost())
235 ->assign('port', $this->getConfiguredOrDefaultPort())
236 ->assign('database', $GLOBALS['TYPO3_CONF_VARS']['DB']['database'] ?: '')
237 ->assign('socket', $GLOBALS['TYPO3_CONF_VARS']['DB']['socket'] ?: '');
238
239 if ($isDbalEnabled) {
240 $this->view->assign('selectedDbalDriver', $this->getSelectedDbalDriver());
241 $this->view->assign('dbalDrivers', $this->getAvailableDbalDrivers());
242 $this->setDbalInputFieldsToRender();
243 } else {
244 $this->view
245 ->assign('renderConnectDetailsUsername', TRUE)
246 ->assign('renderConnectDetailsPassword', TRUE)
247 ->assign('renderConnectDetailsHost', TRUE)
248 ->assign('renderConnectDetailsPort', TRUE)
249 ->assign('renderConnectDetailsSocket', TRUE);
250 }
251
252 return $this->view->render();
253 }
254
255 /**
256 * Render connect port and label
257 *
258 * @return integer Configured or default port
259 */
260 protected function getConfiguredOrDefaultPort() {
261 $configuredPort = (int)$this->getConfiguredPort();
262 if (!$configuredPort) {
263 if ($this->isDbalEnabled()) {
264 $driver = $this->getSelectedDbalDriver();
265 switch ($driver) {
266 case 'postgres':
267 $port = 5432;
268 break;
269 case 'mssql':
270 case 'odbc_mssql':
271 $port = 1433;
272 break;
273 case 'oci8':
274 $port = 1521;
275 break;
276 default:
277 $port = 3306;
278 }
279 } else {
280 $port = 3306;
281 }
282 } else {
283 $port = $configuredPort;
284 }
285 return $port;
286 }
287
288 /**
289 * Test connection with given credentials
290 *
291 * @return boolean TRUE if connect was successful
292 */
293 protected function isConnectSuccessful() {
294 /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
295 $databaseConnection = $this->objectManager->get('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
296
297 if ($this->isDbalEnabled()) {
298 // Set additional connect information based on dbal driver. postgres for example needs
299 // database name already for connect.
300 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['database'])) {
301 $databaseConnection->setDatabaseName($GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
302 }
303 }
304
305 $databaseConnection->setDatabaseUsername($this->getConfiguredUsername());
306 $databaseConnection->setDatabasePassword($this->getConfiguredPassword());
307 $databaseConnection->setDatabaseHost($this->getConfiguredHost());
308 $databaseConnection->setDatabasePort($this->getConfiguredPort());
309 $databaseConnection->setDatabaseSocket($this->getConfiguredSocket());
310
311 $result = FALSE;
312 if (@$databaseConnection->sql_pconnect()) {
313 $result = TRUE;
314 }
315 return $result;
316 }
317
318 /**
319 * Check LocalConfiguration.php for required database settings:
320 * - 'host' is mandatory and must not be empty
321 * - 'port' OR 'socket' is mandatory, but may be empty
322 *
323 * @return boolean TRUE if host is set
324 */
325 protected function isHostConfigured() {
326 $hostConfigured = TRUE;
327 if (empty($GLOBALS['TYPO3_CONF_VARS']['DB']['host'])) {
328 $hostConfigured = FALSE;
329 }
330 if (
331 !isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port'])
332 && !isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket'])
333 ) {
334 $hostConfigured = FALSE;
335 }
336 return $hostConfigured;
337 }
338
339 /**
340 * Check LocalConfiguration.php for required database settings:
341 * - 'host' is mandatory and must not be empty
342 * - 'port' OR 'socket' is mandatory, but may be empty
343 * - 'username' and 'password' are mandatory, but may be empty
344 *
345 * @return boolean TRUE if required settings are present
346 */
347 protected function isConfigurationComplete() {
348 $configurationComplete = $this->isHostConfigured();
349 if (!isset($GLOBALS['TYPO3_CONF_VARS']['DB']['username'])) {
350 $configurationComplete = FALSE;
351 }
352 if (!isset($GLOBALS['TYPO3_CONF_VARS']['DB']['password'])) {
353 $configurationComplete = FALSE;
354 }
355 return $configurationComplete;
356 }
357
358 /**
359 * Write DB settings to LocalConfiguration.php, using default values.
360 * With the switch from mysql to mysqli in 6.1, some mandatory settings were
361 * added. This method tries to add those settings in case of an upgrade, and
362 * pre-configures settings in case of a "new" install process.
363 *
364 * There are two different connection types:
365 * - Unix domain socket. This may be available if mysql is running on localhost
366 * - TCP/IP connection to some mysql system somewhere.
367 *
368 * Unix domain socket connections are quicker than TCP/IP, so it is
369 * tested if a unix domain socket connection to localhost is successful. If not,
370 * a default configuration for TCP/IP is used.
371 *
372 * @return void
373 */
374 protected function useDefaultValuesForNotConfiguredOptions() {
375 $localConfigurationPathValuePairs = array();
376
377 $localConfigurationPathValuePairs['DB/host'] = $this->getConfiguredHost();
378
379 // If host is "local" either by upgrading or by first install, we try a socket
380 // connection first and use TCP/IP as fallback
381 if ($localConfigurationPathValuePairs['DB/host'] === 'localhost'
382 || \TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP($localConfigurationPathValuePairs['DB/host'], '127.*.*.*')
383 || strlen($localConfigurationPathValuePairs['DB/host']) === 0
384 ) {
385 if ($this->isConnectionWithUnixDomainSocketPossible()) {
386 $localConfigurationPathValuePairs['DB/host'] = 'localhost';
387 $localConfigurationPathValuePairs['DB/socket'] = $this->getConfiguredSocket();
388 } else {
389 if (!\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($localConfigurationPathValuePairs['DB/host'], '127.')) {
390 $localConfigurationPathValuePairs['DB/host'] = '127.0.0.1';
391 }
392 }
393 }
394
395 if (!isset($localConfigurationPathValuePairs['DB/socket'])) {
396 // Make sure a default port is set if not configured yet
397 // This is independent from any host configuration
398 $port = $this->getConfiguredPort();
399 if ($port > 0) {
400 $localConfigurationPathValuePairs['DB/port'] = $port;
401 } else {
402 $localConfigurationPathValuePairs['DB/port'] = $this->getConfiguredOrDefaultPort();
403 }
404 }
405
406 /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
407 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
408 $configurationManager->setLocalConfigurationValuesByPathValuePairs($localConfigurationPathValuePairs);
409 }
410
411 /**
412 * Test if a unix domain socket can be opened. This does not
413 * authenticate but only tests if a connect is successful.
414 *
415 * @return boolean TRUE on success
416 */
417 protected function isConnectionWithUnixDomainSocketPossible() {
418 $result = FALSE;
419 // Use configured socket
420 $socket = $this->getConfiguredSocket();
421 if (!strlen($socket) > 0) {
422 // If no configured socket, use default php socket
423 $defaultSocket = ini_get('mysqli.default_socket');
424 if (strlen($defaultSocket) > 0) {
425 $socket = $defaultSocket;
426 }
427 }
428 if (strlen($socket) > 0) {
429 $socketOpenResult = @fsockopen('unix://' . $socket);
430 if ($socketOpenResult) {
431 fclose($socketOpenResult);
432 $result = TRUE;
433 }
434 }
435 return $result;
436 }
437
438 /**
439 * Render fields required for successful connect based on dbal driver selection.
440 * Hint: There is a code duplication in handle() and this method. This
441 * is done by intention to keep this code area easy to maintain and understand.
442 *
443 * @return void
444 */
445 protected function setDbalInputFieldsToRender() {
446 $driver = $this->getSelectedDbalDriver();
447 switch($driver) {
448 case 'mssql':
449 case 'odbc_mssql':
450 case 'postgres':
451 $this->view
452 ->assign('renderConnectDetailsUsername', TRUE)
453 ->assign('renderConnectDetailsPassword', TRUE)
454 ->assign('renderConnectDetailsHost', TRUE)
455 ->assign('renderConnectDetailsPort', TRUE)
456 ->assign('renderConnectDetailsDatabase', TRUE);
457 break;
458 case 'oci8':
459 $this->view
460 ->assign('renderConnectDetailsUsername', TRUE)
461 ->assign('renderConnectDetailsPassword', TRUE)
462 ->assign('renderConnectDetailsHost', TRUE)
463 ->assign('renderConnectDetailsPort', TRUE)
464 ->assign('renderConnectDetailsDatabase', TRUE)
465 ->assign('renderConnectDetailsOracleSidConnect', TRUE);
466 $type = isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['handlerCfg']['_DEFAULT']['config']['driverOptions']['connectSID'])
467 ? $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['handlerCfg']['_DEFAULT']['config']['driverOptions']['connectSID']
468 : '';
469 if ($type === TRUE) {
470 $this->view->assign('oracleSidSelected', TRUE);
471 }
472 break;
473 }
474 }
475
476 /**
477 * Returns a list of database drivers that are available on current server.
478 *
479 * @return array
480 */
481 protected function getAvailableDbalDrivers() {
482 $supportedDrivers = $this->getSupportedDbalDrivers();
483 $availableDrivers = array();
484 $selectedDbalDriver = $this->getSelectedDbalDriver();
485 foreach ($supportedDrivers as $abstractionLayer => $drivers) {
486 foreach ($drivers as $driver => $info) {
487 if (isset($info['combine']) && $info['combine'] === 'OR') {
488 $isAvailable = FALSE;
489 } else {
490 $isAvailable = TRUE;
491 }
492 // Loop through each PHP module dependency to ensure it is loaded
493 foreach ($info['extensions'] as $extension) {
494 if (isset($info['combine']) && $info['combine'] === 'OR') {
495 $isAvailable |= extension_loaded($extension);
496 } else {
497 $isAvailable &= extension_loaded($extension);
498 }
499 }
500 if ($isAvailable) {
501 if (!isset($availableDrivers[$abstractionLayer])) {
502 $availableDrivers[$abstractionLayer] = array();
503 }
504 $availableDrivers[$abstractionLayer][$driver] = array();
505 $availableDrivers[$abstractionLayer][$driver]['driver'] = $driver;
506 $availableDrivers[$abstractionLayer][$driver]['label'] = $info['label'];
507 $availableDrivers[$abstractionLayer][$driver]['selected'] = FALSE;
508 if ($selectedDbalDriver === $driver) {
509 $availableDrivers[$abstractionLayer][$driver]['selected'] = TRUE;
510 }
511 }
512 }
513 }
514 return $availableDrivers;
515 }
516
517 /**
518 * Returns a list of DBAL supported database drivers, with a
519 * user-friendly name and any PHP module dependency.
520 *
521 * @return array
522 */
523 protected function getSupportedDbalDrivers() {
524 $supportedDrivers = array(
525 'Native' => array(
526 'mssql' => array(
527 'label' => 'Microsoft SQL Server',
528 'extensions' => array('mssql')
529 ),
530 'oci8' => array(
531 'label' => 'Oracle OCI8',
532 'extensions' => array('oci8')
533 ),
534 'postgres' => array(
535 'label' => 'PostgreSQL',
536 'extensions' => array('pgsql')
537 )
538 ),
539 'ODBC' => array(
540 'odbc_mssql' => array(
541 'label' => 'Microsoft SQL Server',
542 'extensions' => array('odbc', 'mssql')
543 )
544 )
545 );
546 return $supportedDrivers;
547 }
548
549 /**
550 * Get selected dbal driver if any
551 *
552 * @return string Dbal driver or empty string if not yet selected
553 */
554 protected function getSelectedDbalDriver() {
555 if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['handlerCfg']['_DEFAULT']['config']['driver'])) {
556 return $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['handlerCfg']['_DEFAULT']['config']['driver'];
557 }
558 return '';
559 }
560
561 /**
562 * Adds dbal and adodb to list of loaded extensions
563 *
564 * @return \TYPO3\CMS\Install\Status\StatusInterface
565 */
566 protected function executeLoadDbalExtension() {
567 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('adodb')) {
568 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtension('adodb');
569 }
570 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('dbal')) {
571 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtension('dbal');
572 }
573 /** @var $errorStatus \TYPO3\CMS\Install\Status\WarningStatus */
574 $warningStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\WarningStatus');
575 $warningStatus->setTitle('Loaded database abstraction layer');
576 return $warningStatus;
577 }
578
579 /**
580 * Remove dbal and adodb from list of loaded extensions
581 *
582 * @return \TYPO3\CMS\Install\Status\StatusInterface
583 */
584 protected function executeUnloadDbalExtension() {
585 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('adodb')) {
586 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::unloadExtension('adodb');
587 }
588 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('dbal')) {
589 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::unloadExtension('dbal');
590 }
591 // @TODO: Remove configuration from TYPO3_CONF_VARS['EXTCONF']['dbal']
592 /** @var $errorStatus \TYPO3\CMS\Install\Status\WarningStatus */
593 $warningStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\WarningStatus');
594 $warningStatus->setTitle('Removed database abstraction layer');
595 return $warningStatus;
596 }
597
598 /**
599 * Returns configured username, if set
600 *
601 * @return string
602 */
603 protected function getConfiguredUsername() {
604 $username = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['username']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['username'] : '';
605 return $username;
606 }
607
608 /**
609 * Returns configured password, if set
610 *
611 * @return string
612 */
613 protected function getConfiguredPassword() {
614 $password = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['password']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['password'] : '';
615 return $password;
616 }
617
618 /**
619 * Returns configured host with port split off if given
620 *
621 * @return string
622 */
623 protected function getConfiguredHost() {
624 $host = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['host']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['host'] : '';
625 $port = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['port'] : '';
626 if (strlen($port) < 1 && substr_count($host, ':') === 1) {
627 list($host) = explode(':', $host);
628 }
629 return $host;
630 }
631
632 /**
633 * Returns configured port. Gets port from host value if port is not yet set.
634 *
635 * @return integer
636 */
637 protected function getConfiguredPort() {
638 $host = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['host']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['host'] : '';
639 $port = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['port'] : '';
640 if (strlen($port) === 0 && substr_count($host, ':') === 1) {
641 $hostPortArray = explode(':', $host);
642 $port = $hostPortArray[1];
643 }
644 return (int)$port;
645 }
646
647 /**
648 * Returns configured socket, if set
649 *
650 * @return string|NULL
651 */
652 protected function getConfiguredSocket() {
653 $socket = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['socket'] : '';
654 return $socket;
655 }
656 }