You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: Bug report
about: Database migration uses wrong database when initialising migration classes (similar as #1531)
The following code crashes or is writing data into a completely different database under the assumption that the passed connection interface $db is not equivalent to a connection interface that is defined in any configuration file and therefore is not associated to any group:
$migrate = \Config\Services::migrations(null,$db); // migration configuration must allow/enable migration! $migrate->current($group); // the content of $group determines if the program crashes ($group does relate to a valid connection interface) or if data may be written to a wrong database ($group relates to a valid connection interface)
The root cause of this problem is this line in MigrationRunner.php version():
$instance = new $class(\Config\Database::forge($this->group));
The migration class is initialised with a wrong forge class object. The correct statement should be:
$instance = new $class(new \CodeIgniter\Database\Forge($this->db));
PS: It seems to be that in MigrationRunner the relation between database and group variables is not well separated (see also bug #1531).
CodeIgniter 4 version
CodeIgniter 4.0.0 Alpha 2
Affected module(s)
MigrationRunner.php
The text was updated successfully, but these errors were encountered:
Your fix isn't quite right. Simply creating a new instance of the Forge class completely skips loading the database-specific forge class. The fix looks to be a little more complicated, but will get it fixed.
Sorry, I did not even know that there is a database-specific forge class.
But why do we have then a public (and not protected) constructor? It seems to be that it does not make sense to instantiate a non-database specific forge class anyway.
PS: It would be nice to have the inheritance diagram of classes somewhere listed in the documentation.
name: Bug report
about: Database migration uses wrong database when initialising migration classes (similar as #1531)
The following code crashes or is writing data into a completely different database under the assumption that the passed connection interface $db is not equivalent to a connection interface that is defined in any configuration file and therefore is not associated to any group:
$migrate = \Config\Services::migrations(null,$db); // migration configuration must allow/enable migration! $migrate->current($group); // the content of $group determines if the program crashes ($group does relate to a valid connection interface) or if data may be written to a wrong database ($group relates to a valid connection interface)
The root cause of this problem is this line in MigrationRunner.php version():
$instance = new $class(\Config\Database::forge($this->group));
The migration class is initialised with a wrong forge class object. The correct statement should be:
$instance = new $class(new \CodeIgniter\Database\Forge($this->db));
PS: It seems to be that in MigrationRunner the relation between database and group variables is not well separated (see also bug #1531).
CodeIgniter 4 version
CodeIgniter 4.0.0 Alpha 2
Affected module(s)
MigrationRunner.php
The text was updated successfully, but these errors were encountered: