summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Aker <greg@gregaker.net>2011-12-25 07:20:58 +0100
committerGreg Aker <greg@gregaker.net>2011-12-25 07:20:58 +0100
commit39b441c5d37b5345ee73e716d423750c12ecaad3 (patch)
tree1e3f1b1c82efed021d606bdd24f9751d242666d0
parentf41c9cfbda27c71a1f34ef1ba7e15cad93564691 (diff)
parentdd4702f39c363f1cb9d47fe642001a27963e405a (diff)
Merge pull request #819 from narfbg/develop-migration
Improve the Migration library
-rw-r--r--system/libraries/Migration.php24
1 files changed, 9 insertions, 15 deletions
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 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -101,12 +101,9 @@ class CI_Migration {
}
// Do we auto migrate to the latest migration?
- if ($this->_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 */