Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
c3b622ab
Commit
c3b622ab
authored
Jan 05, 2018
by
Steve Porter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fixes dsn connection strings by url encoding
parent
f12f766d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
7 deletions
+39
-7
Connection.php
src/Jenssegers/Mongodb/Connection.php
+39
-7
No files found.
src/Jenssegers/Mongodb/Connection.php
View file @
c3b622ab
...
...
@@ -150,18 +150,37 @@ class Connection extends BaseConnection
}
/**
*
Create a DSN string from a configuration
.
*
Determine if the given configuration array has a UNIX socket value
.
*
* @param array $config
* @param array $config
* @return bool
*/
protected
function
hasDsnString
(
array
$config
)
{
return
isset
(
$config
[
'dsn'
])
&&
!
empty
(
$config
[
'dsn'
]);
}
/**
* Get the DSN string for a socket configuration.
*
* @param array $config
* @return string
*/
protected
function
getDsn
(
array
$config
)
protected
function
getDsn
String
(
array
$config
)
{
// Check if the user passed a complete dsn to the configuration.
if
(
!
empty
(
$config
[
'dsn'
]))
{
return
$config
[
'dsn'
]
;
}
$dsn
=
rawurlencode
(
$config
[
'dsn'
]);
return
"mongodb://
{
$dsn
}
"
;
}
/**
* Get the DSN string for a host / port configuration.
*
* @param array $config
* @return string
*/
protected
function
getHostDsn
(
array
$config
)
{
// Treat host option as array of hosts
$hosts
=
is_array
(
$config
[
'host'
])
?
$config
[
'host'
]
:
[
$config
[
'host'
]];
...
...
@@ -178,6 +197,19 @@ class Connection extends BaseConnection
return
'mongodb://'
.
implode
(
','
,
$hosts
)
.
(
$auth_database
?
'/'
.
$auth_database
:
''
);
}
/**
* Create a DSN string from a configuration.
*
* @param array $config
* @return string
*/
protected
function
getDsn
(
array
$config
)
{
return
$this
->
hasDsnString
(
$config
)
?
$this
->
getDsnString
(
$config
)
:
$this
->
getHostDsn
(
$config
);
}
/**
* @inheritdoc
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment