From 7a68f7fed163a51d649cb14d960007d470610cac Mon Sep 17 00:00:00 2001 From: bigclick Date: Mon, 21 Nov 2011 11:43:51 +1100 Subject: [PATCH 1/2] 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 259391223..8ae460c95 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -64,7 +64,7 @@ class SchemaShell extends Shell { $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 @@ class SchemaShell extends Shell { 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 @@ class SchemaShell extends Shell { 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 @@ class SchemaShell extends Shell { $count = $numToUse; } } - - $fileName = rtrim($this->params['file'], '.php'); + $content['file'] = $fileName . '_' . $count . '.php'; } @@ -530,4 +530,4 @@ class SchemaShell extends Shell { )); return $parser; } -} +} \ No newline at end of file From 037f2c016e20ecad0c6148abcc892eff0244f0be Mon Sep 17 00:00:00 2001 From: bigclick Date: Mon, 21 Nov 2011 13:19:57 +1100 Subject: [PATCH 2/2] preg_quote'd $fileName to avoid issues when using a special character in their schema filename --- lib/Cake/Console/Command/SchemaShell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 8ae460c95..d8d03dd44 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -170,7 +170,7 @@ class SchemaShell extends Shell { $count = 0; if (!empty($result[1])) { foreach ($result[1] as $file) { - if (preg_match('/'.$fileName.'(?:[_\d]*)?\.php$/', $file)) { + if (preg_match('/'.preg_quote($fileName).'(?:[_\d]*)?\.php$/', $file)) { $count++; } }