summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-25 10:47:45 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-25 10:47:45 +0100
commit3a9f325cdff1fda2f2b37498a689ac2cde058195 (patch)
tree846b3f4c8aa1396a5a61c418c31520285e69b6f5 /system/libraries
parentde9ec100e05f698541422f34e72d9dfee044cc66 (diff)
Use strings instead of integers for migration version numbers
- Allows timestamp versions to work on 32-bit systems. - Fixes #2902. - Supersedes PR #2368.
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Migration.php29
1 files changed, 15 insertions, 14 deletions
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index 2ead3aec1..b226ee804 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -179,13 +179,14 @@ class CI_Migration {
* Calls each migration step required to get to the schema version of
* choice
*
- * @param int $target_version Target schema version
- * @return mixed TRUE if already latest, FALSE if failed, int if upgraded
+ * @param string $target_version Target schema version
+ * @return mixed TRUE if already latest, FALSE if failed, string if upgraded
*/
public function version($target_version)
{
- $current_version = (int) $this->_get_version();
- $target_version = (int) $target_version;
+ // Note: We use strings, so that timestamp versions work on 32-bit systems
+ $current_version = $this->_get_version();
+ $target_version = (string) $target_version;
$migrations = $this->find_migrations();
@@ -224,7 +225,7 @@ class CI_Migration {
return FALSE;
}
- include_once $file;
+ include_once($file);
$class = 'Migration_'.ucfirst(strtolower($this->_get_migration_name(basename($file, '.php'))));
// Validate the migration file structure
@@ -274,7 +275,7 @@ class CI_Migration {
/**
* Sets the schema to the latest migration
*
- * @return mixed TRUE if already latest, FALSE if failed, int if upgraded
+ * @return mixed TRUE if already latest, FALSE if failed, string if upgraded
*/
public function latest()
{
@@ -289,7 +290,7 @@ class CI_Migration {
$last_migration = basename(end($migrations));
// Calculate the last migration step from existing migration
- // filenames and procceed to the standard version migration
+ // filenames and proceed to the standard version migration
return $this->version($this->_get_migration_number($last_migration));
}
@@ -298,7 +299,7 @@ class CI_Migration {
/**
* Sets the schema to the migration version set in config
*
- * @return mixed TRUE if already current, FALSE if failed, int if upgraded
+ * @return mixed TRUE if already current, FALSE if failed, string if upgraded
*/
public function current()
{
@@ -359,12 +360,12 @@ class CI_Migration {
* Extracts the migration number from a filename
*
* @param string $migration
- * @return int Numeric portion of a migration filename
+ * @return string Numeric portion of a migration filename
*/
protected function _get_migration_number($migration)
{
- return sscanf($migration, '%d', $number)
- ? $number : 0;
+ return sscanf($migration, '%[0-9]+', $number)
+ ? $number : '0';
}
// --------------------------------------------------------------------
@@ -387,12 +388,12 @@ class CI_Migration {
/**
* Retrieves current schema version
*
- * @return int Current Migration
+ * @return string Current migration version
*/
protected function _get_version()
{
$row = $this->db->select('version')->get($this->_migration_table)->row();
- return $row ? $row->version : 0;
+ return $row ? $row->version : '0';
}
// --------------------------------------------------------------------
@@ -400,7 +401,7 @@ class CI_Migration {
/**
* Stores the current schema version
*
- * @param int $migration Migration reached
+ * @param string $migration Migration reached
* @return void Outputs a report of the migration
*/
protected function _update_version($migration)