Code Igniter 4.3.1
In class vendor/codeigniter4/framework/system/Database/Seeder.php we have :
PHP Code:
public function __construct(Database $config, ?BaseConnection $db = null)
{
$this->seedPath = $config->filesPath ?? APPPATH . 'Database/';
if (empty($this->seedPath)) {
throw new InvalidArgumentException('Invalid filesPath set in the Config\Database.');
}
$this->seedPath = rtrim($this->seedPath, '\\/') . '/Seeds/';
if (! is_dir($this->seedPath)) {
throw new InvalidArgumentException('Unable to locate the seeds directory. Please check Config\Database::filesPath');
}
$this->config = &$config;
$db ??= Database::connect($this->DBGroup);
$this->db = $db;
$this->forge = Database::forge($this->DBGroup);
}
The line (94 in the code) is not correct :
PHP Code:
$db ??= Database::connect($this->DBGroup);
The fusion null operator (??) is suffixed with an equal sign (=). The connection should be instantiated there only if $db is null by $DBGroup, which does not work!
It sould be written:
PHP Code:
$db ?? Database::connect($this->DBGroup);