Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
b8a5cb22
Unverified
Commit
b8a5cb22
authored
Apr 10, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not require hostname for non-persistent MySQL connection and require for persistent
parent
14f5f154
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
HostRequired.php
src/Driver/Mysqli/HostRequired.php
+16
-0
MysqliConnection.php
src/Driver/Mysqli/MysqliConnection.php
+7
-2
MysqliConnectionTest.php
tests/Driver/Mysqli/MysqliConnectionTest.php
+7
-0
No files found.
src/Driver/Mysqli/HostRequired.php
0 → 100644
View file @
b8a5cb22
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\DBAL\Driver\Mysqli
;
/**
* @internal
*/
final
class
HostRequired
extends
MysqliException
{
public
static
function
forPersistentConnection
()
:
self
{
return
new
self
(
'The "host" parameter is required for a persistent connection'
);
}
}
src/Driver/Mysqli/MysqliConnection.php
View file @
b8a5cb22
...
...
@@ -49,11 +49,16 @@ class MysqliConnection implements PingableConnection, ServerInfoAwareConnection
{
$socket
=
$params
[
'unix_socket'
]
??
ini_get
(
'mysqli.default_socket'
);
$dbname
=
$params
[
'dbname'
]
??
null
;
$host
=
$params
[
'host'
];
$port
=
$params
[
'port'
]
??
null
;
if
(
!
empty
(
$params
[
'persistent'
]))
{
$host
=
'p:'
.
$host
;
if
(
!
isset
(
$params
[
'host'
]))
{
throw
HostRequired
::
forPersistentConnection
();
}
$host
=
'p:'
.
$params
[
'host'
];
}
else
{
$host
=
$params
[
'host'
]
??
null
;
}
$flags
=
$driverOptions
[
static
::
OPTION_FLAGS
]
??
null
;
...
...
tests/Driver/Mysqli/MysqliConnectionTest.php
View file @
b8a5cb22
...
...
@@ -2,6 +2,7 @@
namespace
Doctrine\DBAL\Tests\Driver\Mysqli
;
use
Doctrine\DBAL\Driver\Mysqli\HostRequired
;
use
Doctrine\DBAL\Driver\Mysqli\MysqliConnection
;
use
Doctrine\DBAL\Driver\Mysqli\MysqliException
;
use
Doctrine\DBAL\Platforms\MySqlPlatform
;
...
...
@@ -60,4 +61,10 @@ class MysqliConnectionTest extends FunctionalTestCase
restore_error_handler
();
restore_error_handler
();
}
public
function
testHostnameIsRequiredForPersistentConnection
()
:
void
{
$this
->
expectException
(
HostRequired
::
class
);
new
MysqliConnection
([
'persistent'
=>
'true'
],
''
,
''
);
}
}
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