From 7a68f7fed163a51d649cb14d960007d470610cac Mon Sep 17 00:00:00 2001 From: bigclick Date: Mon, 21 Nov 2011 11:43:51 +1100 Subject: [PATCH] Fix for when trying to use "Console/cake schema generate snapshot" command, line 67 was making the name param snapshot, also fixed auto numbering in the case where the filename wasn't "schema" --- lib/Cake/Console/Command/SchemaShell.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 259391223b6..8ae460c9521 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -64,7 +64,7 @@ public function startup() { $name = $path = $connection = $plugin = null; if (!empty($this->params['name'])) { $name = $this->params['name']; - } elseif (!empty($this->args[0])) { + } elseif (!empty($this->args[0]) && $this->args[0] !== 'snapshot') { $name = $this->params['name'] = $this->args[0]; } @@ -158,6 +158,7 @@ public function generate() { Configure::write('Cache.disable', $cacheDisable); if ($snapshot === true) { + $fileName = rtrim($this->params['file'], '.php'); $Folder = new Folder($this->Schema->path); $result = $Folder->read(); @@ -165,11 +166,11 @@ public function generate() { if (isset($this->params['snapshot'])) { $numToUse = $this->params['snapshot']; } - + $count = 0; if (!empty($result[1])) { foreach ($result[1] as $file) { - if (preg_match('/schema(?:[_\d]*)?\.php$/', $file)) { + if (preg_match('/'.$fileName.'(?:[_\d]*)?\.php$/', $file)) { $count++; } } @@ -180,8 +181,7 @@ public function generate() { $count = $numToUse; } } - - $fileName = rtrim($this->params['file'], '.php'); + $content['file'] = $fileName . '_' . $count . '.php'; } @@ -530,4 +530,4 @@ public function getOptionParser() { )); return $parser; } -} +} \ No newline at end of file