diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 1b780892..9f5b47f1 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -281,6 +281,10 @@ public function version($target_version) include_once($file); $class = 'Migration_'.ucfirst(strtolower($this->_get_migration_name(basename($file, '.php')))); + + // Add the following line as part of change to allow compatibility with PHP 8 + $instance = new $class; + // Validate the migration file structure if ( ! class_exists($class, FALSE)) @@ -288,12 +292,27 @@ 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))) + + + //elseif ( ! is_callable(array($class, $method))) + + // The following modification is required for PHP 8 + elseif ( ! is_callable(array($instance, $method))) + { + $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); + return FALSE; + } +/** Does not work under PHP 8 + elseif ( ! in_array($method, array_map('strtolower', get_class_methods($class)))) + + + + { $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); return FALSE; } - +*/ $pending[$number] = array($class, $method); }