From 0c29a7e1b1f16329e0eb3e7b3b7cd88fe534e4b8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 23 Dec 2008 20:30:20 +0000 Subject: [PATCH] Updating Schema shell so before() and after() are properly triggered. Fixes #5918 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7952 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/console/libs/schema.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/console/libs/schema.php b/cake/console/libs/schema.php index 06f863931..799bb0083 100644 --- a/cake/console/libs/schema.php +++ b/cake/console/libs/schema.php @@ -305,7 +305,7 @@ class SchemaShell extends Shell { if ('y' == $this->in(__('Are you sure you want to drop the table(s)?', true), array('y', 'n'), 'n')) { $this->out('Dropping table(s).'); - $this->__run($drop, 'drop'); + $this->__run($drop, 'drop', $Schema); } $this->out("\n" . __('The following table(s) will be created.', true)); @@ -313,7 +313,7 @@ class SchemaShell extends Shell { if ('y' == $this->in(__('Are you sure you want to create the table(s)?', true), array('y', 'n'), 'y')) { $this->out('Creating table(s).'); - $this->__run($create, 'create'); + $this->__run($create, 'create', $Schema); } $this->out(__('End create.', true)); @@ -351,7 +351,7 @@ class SchemaShell extends Shell { if ('y' == $this->in(__('Are you sure you want to alter the tables?', true), array('y', 'n'), 'n')) { $this->out(''); $this->out(__('Updating Database...', true)); - $this->__run($contents, 'update'); + $this->__run($contents, 'update', $Schema); } $this->out(__('End update.', true)); @@ -361,7 +361,7 @@ class SchemaShell extends Shell { * * @access private */ - function __run($contents, $event) { + function __run($contents, $event, $Schema) { if (empty($contents)) { $this->err(__('Sql could not be run', true)); return; @@ -379,14 +379,14 @@ class SchemaShell extends Shell { $this->out(sprintf(__('Dry run for %s :', true), $table)); $this->out($sql); } else { - if (!$this->Schema->before(array($event => $table))) { + if (!$Schema->before(array($event => $table))) { return false; } if (!$db->_execute($sql)) { $error = $table . ': ' . $db->lastError(); } - $this->Schema->after(array($event => $table, 'errors'=> $errors)); + $Schema->after(array($event => $table, 'errors'=> $errors)); if (isset($error)) { $this->out($error);