From dd4702f39c363f1cb9d47fe642001a27963e405a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Dec 2011 19:33:44 +0200 Subject: Improve the Migration library --- system/libraries/Migration.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 94961b568..eb5161d76 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -1,4 +1,4 @@ -_migration_auto_latest == TRUE) + if ($this->_migration_auto_latest === TRUE AND ! $this->latest()) { - if ( ! $this->latest() ) - { - show_error($this->error_string()); - } + show_error($this->error_string()); } } @@ -134,7 +131,6 @@ class CI_Migration { ++$stop; $step = 1; } - else { // Moving Down @@ -158,11 +154,11 @@ class CI_Migration { } // Migration step not found - if (count($f) == 0) + if (count($f) === 0) { // If trying to migrate up to a version greater than the last // existing one, migrate to the last one. - if ($step == 1) + if ($step === 1) { break; } @@ -214,7 +210,7 @@ class CI_Migration { log_message('debug', 'Current migration: '.$current_version); - $version = $i + ($step == 1 ? -1 : 0); + $version = $i + ($step === 1 ? -1 : 0); // If there is nothing to do so quit if ($migrations === array()) @@ -301,13 +297,11 @@ class CI_Migration { { // Load all *_*.php files in the migrations path $files = glob($this->_migration_path.'*_*.php'); - $file_count = count($files); - for ($i = 0; $i < $file_count; $i++) + for ($i = 0, $c = count($files); $i < $c; $i++) { // Mark wrongly formatted files as false for later filtering - $name = basename($files[$i], '.php'); - if ( ! preg_match('/^\d{3}_(\w+)$/', $name)) + if ( ! preg_match('/^\d{3}_(\w+)$/', basename($files[$i], '.php'))) { $files[$i] = FALSE; } @@ -364,4 +358,4 @@ class CI_Migration { } /* End of file Migration.php */ -/* Location: ./system/libraries/Migration.php */ \ No newline at end of file +/* Location: ./system/libraries/Migration.php */ -- cgit v1.2.3-24-g4f1b