Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
8a79d314
Commit
8a79d314
authored
8 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Remove duplicate database connect logic in mysql setup
parent
2bf7d3a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/private/AllConfig.php
+4
-0
4 additions, 0 deletions
lib/private/AllConfig.php
lib/private/Setup/AbstractDatabase.php
+21
-1
21 additions, 1 deletion
lib/private/Setup/AbstractDatabase.php
lib/private/Setup/MySQL.php
+0
-35
0 additions, 35 deletions
lib/private/Setup/MySQL.php
with
25 additions
and
36 deletions
lib/private/AllConfig.php
+
4
−
0
View file @
8a79d314
...
...
@@ -428,4 +428,8 @@ class AllConfig implements \OCP\IConfig {
return
$userIDs
;
}
public
function
getSystemConfig
()
{
return
$this
->
systemConfig
;
}
}
This diff is collapsed.
Click to expand it.
lib/private/Setup/AbstractDatabase.php
+
21
−
1
View file @
8a79d314
...
...
@@ -23,6 +23,8 @@
*/
namespace
OC\Setup
;
use
OC\AllConfig
;
use
OC\DB\ConnectionFactory
;
use
OCP\IConfig
;
use
OCP\ILogger
;
use
OCP\Security\ISecureRandom
;
...
...
@@ -45,7 +47,7 @@ abstract class AbstractDatabase {
protected
$dbPort
;
/** @var string */
protected
$tablePrefix
;
/** @var
I
Config */
/** @var
All
Config */
protected
$config
;
/** @var ILogger */
protected
$logger
;
...
...
@@ -98,6 +100,24 @@ abstract class AbstractDatabase {
$this
->
tablePrefix
=
$dbTablePrefix
;
}
/**
* @return \OC\DB\Connection
* @throws \OC\DatabaseSetupException
*/
protected
function
connect
()
{
$systemConfig
=
$this
->
config
->
getSystemConfig
();
$cf
=
new
ConnectionFactory
();
$connectionParams
=
$cf
->
createConnectionParams
(
$systemConfig
);
// we don't save username/password to the config immediately so this might not be set
if
(
!
$connectionParams
[
'user'
])
{
$connectionParams
[
'user'
]
=
$this
->
dbUser
;
}
if
(
!
$connectionParams
[
'password'
])
{
$connectionParams
[
'password'
]
=
$this
->
dbPassword
;
}
return
$cf
->
getConnection
(
$systemConfig
->
getValue
(
'dbtype'
,
'sqlite'
),
$connectionParams
);
}
/**
* @param string $userName
*/
...
...
This diff is collapsed.
Click to expand it.
lib/private/Setup/MySQL.php
+
0
−
35
View file @
8a79d314
...
...
@@ -87,41 +87,6 @@ class MySQL extends AbstractDatabase {
$connection
->
executeUpdate
(
$query
);
}
/**
* @return \OC\DB\Connection
* @throws \OC\DatabaseSetupException
*/
private
function
connect
()
{
$connectionParams
=
array
(
'host'
=>
$this
->
dbHost
,
'user'
=>
$this
->
dbUser
,
'password'
=>
$this
->
dbPassword
,
'tablePrefix'
=>
$this
->
tablePrefix
,
);
// adding port support through installer
if
(
!
empty
(
$this
->
dbPort
))
{
if
(
ctype_digit
(
$this
->
dbPort
))
{
$connectionParams
[
'port'
]
=
$this
->
dbPort
;
}
else
{
$connectionParams
[
'unix_socket'
]
=
$this
->
dbPort
;
}
}
else
if
(
strpos
(
$this
->
dbHost
,
':'
))
{
// Host variable may carry a port or socket.
list
(
$host
,
$portOrSocket
)
=
explode
(
':'
,
$this
->
dbHost
,
2
);
if
(
ctype_digit
(
$portOrSocket
))
{
$connectionParams
[
'port'
]
=
$portOrSocket
;
}
else
{
$connectionParams
[
'unix_socket'
]
=
$portOrSocket
;
}
$connectionParams
[
'host'
]
=
$host
;
}
$cf
=
new
ConnectionFactory
();
return
$cf
->
getConnection
(
'mysql'
,
$connectionParams
);
}
/**
* @param $username
* @param IDBConnection $connection
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment