-
Notifications
You must be signed in to change notification settings - Fork 15
/
ext_localconf.php
70 lines (61 loc) · 3.25 KB
/
ext_localconf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
defined('TYPO3') or die();
call_user_func(function () {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['dbalAndAdodbExtraction']
= \TYPO3\CMS\Typo3DbLegacy\Updates\DbalAndAdodbExtractionUpdate::class;
// Initialize database connection in $GLOBALS and connect
$databaseConnection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Typo3DbLegacy\Database\DatabaseConnection::class);
$databaseConnection->setDatabaseName(
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] ?? ''
);
$databaseConnection->setDatabaseUsername(
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['user'] ?? ''
);
$databaseConnection->setDatabasePassword(
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['password'] ?? ''
);
if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['charset'])) {
$databaseConnection->setConnectionCharset($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['charset']);
}
$databaseHost = $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['host'] ?? '';
if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['port'])) {
$databaseConnection->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['port']);
} elseif (strpos($databaseHost, ':') > 0) {
// @TODO: Find a way to handle this case in the install tool and drop this
[$databaseHost, $databasePort] = explode(':', $databaseHost);
$databaseConnection->setDatabasePort($databasePort);
}
if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['unix_socket'])) {
$databaseConnection->setDatabaseSocket(
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['unix_socket']
);
}
$databaseConnection->setDatabaseHost($databaseHost);
$databaseConnection->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'] ?? false;
if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['persistentConnection'])
&& $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['persistentConnection']
) {
$databaseConnection->setPersistentDatabaseConnection(true);
}
$isDatabaseHostLocalHost = in_array($databaseHost, ['localhost', '127.0.0.1', '::1'], true);
if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['driverOptions'])
&& $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['driverOptions'] & MYSQLI_CLIENT_COMPRESS
&& !$isDatabaseHostLocalHost
) {
$databaseConnection->setConnectionCompression(true);
}
if (!empty($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['initCommands'])) {
$commandsAfterConnect = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
LF,
str_replace(
'\' . LF . \'',
LF,
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['initCommands']
),
true
);
$databaseConnection->setInitializeCommandsAfterConnect($commandsAfterConnect);
}
$GLOBALS['TYPO3_DB'] = $databaseConnection;
$GLOBALS['TYPO3_DB']->initialize();
});