Skip to content

Commit

Permalink
Fix migration bug under PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjdann committed May 16, 2024
1 parent ed26c27 commit e6b822d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions system/libraries/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,38 @@ 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))
{
$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);
}

Expand Down

0 comments on commit e6b822d

Please sign in to comment.