Skip to content

Commit 2fc627a

Browse files
author
Yevhen Miroshnychenko
committed
MAGETWO-94241: Mysql reconnect does not work
1 parent d45ba0b commit 2fc627a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

lib/internal/Magento/Framework/DB/Statement/Pdo/Mysql.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
namespace Magento\Framework\DB\Statement\Pdo;
7+
8+
use Magento\Framework\DB\Statement\Parameter;
69

710
/**
811
* Mysql DB Statement
912
*
1013
* @author Magento Core Team <core@magentocommerce.com>
1114
*/
12-
namespace Magento\Framework\DB\Statement\Pdo;
13-
14-
use Magento\Framework\DB\Statement\Parameter;
15-
1615
class Mysql extends \Zend_Db_Statement_Pdo
1716
{
1817
/**
@@ -61,7 +60,7 @@ public function _executeWithBinding(array $params)
6160
$statement->bindParam($paramName, $bindValues[$name], $dataType, $length, $driverOptions);
6261
}
6362

64-
return $this->tryExecute(function() use ($statement) {
63+
return $this->tryExecute(function () use ($statement) {
6564
return $statement->execute();
6665
});
6766
}
@@ -86,9 +85,9 @@ public function _execute(array $params = null)
8685
}
8786

8887
if ($specialExecute) {
89-
return $this->_executeWithBinding($params);
88+
return $this->_executeWithBinding($params);
9089
} else {
91-
return $this->tryExecute(function() use ($params) {
90+
return $this->tryExecute(function () use ($params) {
9291
return $params !== null ? $this->_stmt->execute($params) : $this->_stmt->execute();
9392
});
9493
}

lib/internal/Magento/Framework/DB/Test/Unit/DB/Statement/MysqlTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Framework\DB\Test\Unit\DB\Statement;
78

89
use Magento\Framework\DB\Statement\Parameter;
910
use Magento\Framework\DB\Statement\Pdo\Mysql;
1011
use PHPUnit\Framework\MockObject\MockObject;
1112
use PHPUnit\Framework\TestCase;
1213

14+
/**
15+
* @inheritdoc
16+
*/
1317
class MysqlTest extends TestCase
1418
{
1519
/**
@@ -38,7 +42,8 @@ class MysqlTest extends TestCase
3842
public function setUp()
3943
{
4044
$this->adapterMock = $this->getMockForAbstractClass(
41-
\Zend_Db_Adapter_Abstract::class, [],
45+
\Zend_Db_Adapter_Abstract::class,
46+
[],
4247
'',
4348
false,
4449
true,
@@ -56,7 +61,7 @@ public function setUp()
5661
$this->pdoStatementMock = $this->createMock(\PDOStatement::class);
5762
}
5863

59-
public function test_executeWithoutParams()
64+
public function testExecuteWithoutParams()
6065
{
6166
$query = 'SET @a=1;';
6267
$this->pdoMock->expects($this->once())
@@ -68,13 +73,12 @@ public function test_executeWithoutParams()
6873
(new Mysql($this->adapterMock, $query))->_execute();
6974
}
7075

71-
public function test_executeWhenThrowPDOException()
76+
public function testExecuteWhenThrowPDOException()
7277
{
7378
$this->expectException(\Zend_Db_Statement_Exception::class);
7479
$this->expectExceptionMessage('test message, query was:');
7580
$errorReporting = error_reporting();
7681
$query = 'SET @a=1;';
77-
7882
$this->pdoMock->expects($this->once())
7983
->method('prepare')
8084
->with($query)
@@ -88,12 +92,9 @@ public function test_executeWhenThrowPDOException()
8892
(new Mysql($this->adapterMock, $query))->_execute();
8993
}
9094

91-
public function test_executeWhenParamsAsPrimitives()
95+
public function testExecuteWhenParamsAsPrimitives()
9296
{
93-
$params = [
94-
':param1' => 'value1',
95-
':param2' => 'value2',
96-
];
97+
$params = [':param1' => 'value1', ':param2' => 'value2'];
9798
$query = 'UPDATE `some_table1` SET `col1`=\'val1\' WHERE `param1`=\':param1\' AND `param2`=\':param2\';';
9899
$this->pdoMock->expects($this->once())
99100
->method('prepare')
@@ -108,7 +109,7 @@ public function test_executeWhenParamsAsPrimitives()
108109
(new Mysql($this->adapterMock, $query))->_execute($params);
109110
}
110111

111-
public function test_executeWhenParamsAsParameterObject()
112+
public function testExecuteWhenParamsAsParameterObject()
112113
{
113114
$param1 = $this->createMock(Parameter::class);
114115
$param1Value = 'SomeValue';

0 commit comments

Comments
 (0)