From e1d6c46b7d5e3d82dc6953af29f0b02ccb03e2dc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Nov 2012 19:06:20 +0200 Subject: [PATCH] Fix #2037 --- system/libraries/Migration.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index e96791cefa0..bf2d18e0789 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -233,11 +233,6 @@ public function version($target_version) $this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class); return FALSE; } - elseif ( ! is_callable(array($class, $method))) - { - $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); - return FALSE; - } $previous = $number; @@ -247,8 +242,15 @@ public function version($target_version) ($method === 'down' && $number <= $current_version && $number > $target_version) ) { + $instance = new $class(); + if ( ! is_callable(array($instance, $method))) + { + $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); + return FALSE; + } + log_message('debug', 'Migrating '.$method.' from version '.$current_version.' to version '.$number); - call_user_func(array(new $class, $method)); + call_user_func(array($instance, $method)); $current_version = $number; $this->_update_version($current_version); }