Skip to content

Commit

Permalink
Merge branch 'master' into no-yii-autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
Bizley authored Feb 15, 2021
2 parents b62bce4 + e405ae9 commit fe26e44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function extract(string $migration, array $migrationPaths): void
require_once $file;
}

$this->subject = new $migration(['db' => clone $this->db, 'experimental' => $this->experimental]);
$this->subject = new $migration(['db' => $this->db, 'experimental' => $this->experimental]);
if ($this->subject instanceof MigrationChangesInterface === false) {
throw new ErrorException(
"Class '{$migration}' must implement bizley\migration\dummy\MigrationChangesInterface."
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/BaseMigrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use yii\console\Controller;
use yii\db\Connection;
use yii\db\Query;
use yii\di\Instance;

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

0 comments on commit fe26e44

Please sign in to comment.