Browse Source

Fix file always being set to 'schema.php'

When the name parameter is set and no custom file value is provided,
the name should be used to generate the file name. empty() cannot be
used because the file parameter has a default value of 'schema.php'.

Fixes #2202
mark_story 12 years ago
parent
commit
411f510406
1 changed files with 5 additions and 5 deletions
  1. 5 5
      lib/Cake/Console/Command/SchemaShell.php

+ 5 - 5
lib/Cake/Console/Command/SchemaShell.php

@@ -67,12 +67,12 @@ class SchemaShell extends AppShell {
 			$name = $this->params['name'] = $splitName;
 		}
 
-		if ($name && empty($this->params['file'])) {
-			$this->params['file'] = Inflector::underscore($name);
-		}
-
+		$defaultFile = 'schema.php';
 		if (empty($this->params['file'])) {
-			$this->params['file'] = 'schema.php';
+			$this->params['file'] = $defaultFile;
+		}
+		if ($name && $this->params['file'] === $defaultFile) {
+			$this->params['file'] = Inflector::underscore($name);
 		}
 		if (strpos($this->params['file'], '.php') === false) {
 			$this->params['file'] .= '.php';