Skip to content

Commit b85793c

Browse files
Merge pull request #147 from DaveHewy/master
Patch all occurences of phpmig.sets with deep level key access w/o parent
2 parents 8b30615 + ac95e3d commit b85793c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: src/Phpmig/Console/Command/AbstractCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected function bootstrapMigrations(InputInterface $input, OutputInterface $o
173173
$container = $this->getContainer();
174174
$set = $input->getOption('set');
175175

176-
if (!isset($container['phpmig.migrations']) && !isset($container['phpmig.migrations_path']) && !isset($container['phpmig.sets'][$set]['migrations_path'])) {
176+
if (!isset($container['phpmig.migrations']) && !isset($container['phpmig.migrations_path']) && (isset($container['phpmig.sets']) && !isset($container['phpmig.sets'][$set]['migrations_path']))) {
177177
throw new \RuntimeException($this->getBootstrap() . ' must return container with array at phpmig.migrations or migrations default path at phpmig.migrations_path or migrations default path at phpmig.sets');
178178
}
179179

@@ -398,4 +398,4 @@ private function isValidClassName($className)
398398
{
399399
return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $className) === 1;
400400
}
401-
}
401+
}

Diff for: src/Phpmig/Console/Command/GenerateCommand.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
6060
if (true === isset($this->container['phpmig.migrations_path'])) {
6161
$path = $this->container['phpmig.migrations_path'];
6262
}
63-
if (true === isset($this->container['phpmig.sets'][$set]['migrations_path'])) {
64-
$path = $this->container['phpmig.sets'][$set]['migrations_path'];
65-
}
63+
// do not deep link to nested keys without first testing the parent key
64+
if (true === isset($this->container['phpmig.sets'])){
65+
if (true === isset($this->container['phpmig.sets'][$set]['migrations_path'])) {
66+
$path = $this->container['phpmig.sets'][$set]['migrations_path'];
67+
}
68+
}
6669
}
6770
$locator = new FileLocator(array());
6871
$path = $locator->locate($path, getcwd(), $first = true);
@@ -91,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9194

9295
$className = $this->migrationToClassName($migrationName);
9396

94-
if (isset($this->container['phpmig.migrations_template_path']) || isset($this->container['phpmig.sets'][$set]['migrations_template_path'])) {
97+
if (isset($this->container['phpmig.migrations_template_path']) || (isset($this->container['phpmig.sets']) && isset($this->container['phpmig.sets'][$set]['migrations_template_path']))) {
9598
if (true === isset($this->container['phpmig.migrations_template_path'])) {
9699
$migrationsTemplatePath = $this->container['phpmig.migrations_template_path'];
97100
} else {

0 commit comments

Comments
 (0)