Skip to content

Commit 0931e3a

Browse files
ENGCOM-8825: Restore UNIQUE_CHECKS mysql variable to its original value when done … #32286
- Merge Pull Request #32286 from hostep/magento2:fix-for-issue-32283 - Merged commits: 1. 2979876
2 parents ea236e7 + 2979876 commit 0931e3a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/internal/Magento/Framework/Setup/Declaration/Schema/OperationsExecutor.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ public function getDestructiveOperations()
132132
private function startSetupForAllConnections()
133133
{
134134
foreach ($this->sharding->getResources() as $resource) {
135-
$this->resourceConnection->getConnection($resource)
136-
->startSetup();
137-
$this->resourceConnection->getConnection($resource)
138-
->query('SET UNIQUE_CHECKS=0');
135+
$connection = $this->resourceConnection->getConnection($resource);
136+
137+
$connection->startSetup();
138+
$connection->query('SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0');
139139
}
140140
}
141141

@@ -148,8 +148,10 @@ private function startSetupForAllConnections()
148148
private function endSetupForAllConnections()
149149
{
150150
foreach ($this->sharding->getResources() as $resource) {
151-
$this->resourceConnection->getConnection($resource)
152-
->endSetup();
151+
$connection = $this->resourceConnection->getConnection($resource);
152+
153+
$connection->query('SET UNIQUE_CHECKS=IF(@OLD_UNIQUE_CHECKS=0, 0, 1)');
154+
$connection->endSetup();
153155
}
154156
}
155157

lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/OperationsExecutorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function testExecute()
160160
$connectionMock = $this->getMockBuilder(Mysql::class)
161161
->disableOriginalConstructor()
162162
->getMock();
163-
$this->resourceConnectionMock->expects(self::exactly(3))
163+
$this->resourceConnectionMock->expects(self::exactly(2))
164164
->method('getConnection')
165165
->with('default')
166166
->willReturn($connectionMock);

0 commit comments

Comments
 (0)