Skip to content

Commit fe26e44

Browse files
author
Bizley
authored
Merge branch 'master' into no-yii-autoloader
2 parents b62bce4 + e405ae9 commit fe26e44

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Extractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function extract(string $migration, array $migrationPaths): void
6363
require_once $file;
6464
}
6565

66-
$this->subject = new $migration(['db' => clone $this->db, 'experimental' => $this->experimental]);
66+
$this->subject = new $migration(['db' => $this->db, 'experimental' => $this->experimental]);
6767
if ($this->subject instanceof MigrationChangesInterface === false) {
6868
throw new ErrorException(
6969
"Class '{$migration}' must implement bizley\migration\dummy\MigrationChangesInterface."

src/controllers/BaseMigrationController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use yii\console\Controller;
3737
use yii\db\Connection;
3838
use yii\db\Query;
39+
use yii\di\Instance;
3940

4041
/**
4142
* This is the foundation of MigrationController. All services are registered here.
@@ -278,7 +279,9 @@ public function getGenerator(): GeneratorInterface
278279
public function getExtractor(): ExtractorInterface
279280
{
280281
if ($this->extractor === null) {
281-
$configuredObject = Yii::createObject($this->extractorClass, [$this->db, $this->experimental]);
282+
$db = Instance::ensure($this->db, Connection::class);
283+
// cloning connection here to not force reconnecting on each extraction
284+
$configuredObject = Yii::createObject($this->extractorClass, [clone $db, $this->experimental]);
282285
if (!$configuredObject instanceof ExtractorInterface) {
283286
throw new InvalidConfigException('Extractor must implement bizley\migration\ExtractorInterface.');
284287
}

0 commit comments

Comments
 (0)