Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Bug: [MariaDB] `phpunit` test errors

Đang mở
#7,929 13 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@jalexiscv đang làm issue này rồi.

Từ ngày 18/5/2026.

  • #10208 của @jalexiscv — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
mariadb, mysql, php
Lĩnh vực
databases, testing

Hướng nghiên cứu

Bắt đầu bằng cách chạy vendor/bin/phpunit với cấu hình MariaDB được báo cáo và kiểm tra các bài kiểm thử tests/system/Database/Live/ForgeTest.php, GetVersionTest.php, MetadataTest.php, UpsertTest.php, MySQLi/NumberNativeTest.php và UpdateTest.php tại các lỗi được nêu. So sánh các lỗi giữa MariaDB và MySQL, bao gồm cả DBPrefix đã cấu hình; hoàn thành khi các bài kiểm thử cơ sở dữ liệu live bị ảnh hưởng đều đạt mà không có kỳ vọng được hard-code hoặc dành riêng cho phiên bản.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
PHP Version

8.2

CodeIgniter4 Version

4.4.1

CodeIgniter4 Installation Method

Git

Which operating systems have you tested for this bug?

Linux

Which server did you use?

cli-server (PHP built-in webserver)

Database

10.11.4-MariaDB-1

What happened?
:~/www/codeigniter$ vendor/bin/phpunit
There were 2 failures:

Error №1 (DB is configured in .env )

1) CodeIgniter\Database\Live\ForgeTest::testAddFields
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
     0 => Array &1 (
         'name' => 'id'
         'type' => 'int'
-        'max_length' => null
+        'max_length' => 11
         'nullable' => false
         'default' => null
         'primary_key' => 1
@@ @@
     3 => Array &4 (
         'name' => 'active'
         'type' => 'int'
-        'max_length' => null
+        'max_length' => 11
         'nullable' => false
         'default' => '0'
         'primary_key' => 0
     )
 )

/www/codeigniter/tests/system/Database/Live/ForgeTest.php:1087

Now mysql (8.1.0) and mariadb (10.11.4-MariaDB-1 ) are compatible databases, but they have different versions.

Connection return version as 10.11.4-MariaDB-1:
https://github.com/codeigniter4/CodeIgniter4/blob/f35f956d083eb3872b52af0f578a1a14ba6a471f/tests/system/Database/Live/ForgeTest.php#L944-L950

Maybe you need to rewrite to $this->mysqli->server_version (101104)? This is BC.
Or rewrite the test for different versions of mysql and mariadb.
I commented out the condition and the test is successful.

Error №2 (DB is configured in .env )

2) CodeIgniter\Database\Live\GetVersionTest::testGetVersion
Failed asserting that '10.11.4-MariaDB-1' matches PCRE pattern "/\A\d+(\.\d+)*\z/".

/www/codeigniter/tests/system/Database/Live/GetVersionTest.php:32

The problem is in the versions for mariadb. Related to the first error.

Error №3 (DB is not configured in .env)

The third failure relates to the prefix: Some tests are built on the db_ prefix, others correctly add $prefix. $tableName

Tests are performed only when ENV: database.tests.DBPrefix = db_

It is necessary to replace the hard-coded table names.

phpunit log

  There were 3 errors:
  
  1) CodeIgniter\Database\Live\MySQLi\NumberNativeTest::testQueryDataAfterEnableNumberNative
  CodeIgniter\Database\Exceptions\DatabaseException: Table 'ci4_test.db_type_test' doesn't exist
  
  /www/codeigniter/system/Database/BaseConnection.php:647
  /www/codeigniter/system/Database/BaseBuilder.php:1615
  /www/codeigniter/tests/system/Database/Live/MySQLi/NumberNativeTest.php:78
  
  Caused by
  CodeIgniter\Database\Exceptions\DatabaseException: Table 'ci4_test.db_type_test' doesn't exist
  
  /www/codeigniter/system/Database/MySQLi/Connection.php:311
  /www/codeigniter/system/Database/BaseConnection.php:693
  /www/codeigniter/system/Database/BaseConnection.php:607
  /www/codeigniter/system/Database/BaseBuilder.php:1615
  /www/codeigniter/tests/system/Database/Live/MySQLi/NumberNativeTest.php:78
  
  Caused by
  mysqli_sql_exception: Table 'ci4_test.db_type_test' doesn't exist
  
  /www/codeigniter/system/Database/MySQLi/Connection.php:306
  /www/codeigniter/system/Database/BaseConnection.php:693
  /www/codeigniter/system/Database/BaseConnection.php:607
  /www/codeigniter/system/Database/BaseBuilder.php:1615
  /www/codeigniter/tests/system/Database/Live/MySQLi/NumberNativeTest.php:78
  
  2) CodeIgniter\Database\Live\MySQLi\NumberNativeTest::testQueryDataAfterDisableNumberNative
  CodeIgniter\Database\Exceptions\DatabaseException: Table 'ci4_test.db_type_test' doesn't exist
  
  /www/codeigniter/system/Database/BaseConnection.php:647
  /www/codeigniter/system/Database/BaseBuilder.php:1615
  /www/codeigniter/tests/system/Database/Live/MySQLi/NumberNativeTest.php:96
  
  Caused by
  CodeIgniter\Database\Exceptions\DatabaseException: Table 'ci4_test.db_type_test' doesn't exist
  
  /www/codeigniter/system/Database/MySQLi/Connection.php:311
  /www/codeigniter/system/Database/BaseConnection.php:693
  /www/codeigniter/system/Database/BaseConnection.php:607
  /www/codeigniter/system/Database/BaseBuilder.php:1615
  /www/codeigniter/tests/system/Database/Live/MySQLi/NumberNativeTest.php:96
  
  Caused by
  mysqli_sql_exception: Table 'ci4_test.db_type_test' doesn't exist
  
  /www/codeigniter/system/Database/MySQLi/Connection.php:306
  /www/codeigniter/system/Database/BaseConnection.php:693
  /www/codeigniter/system/Database/BaseConnection.php:607
  /www/codeigniter/system/Database/BaseBuilder.php:1615
  /www/codeigniter/tests/system/Database/Live/MySQLi/NumberNativeTest.php:96
  
  3) CodeIgniter\Database\Live\UpdateTest::testUpdateBatchUpdateFieldsAndAlias
  CodeIgniter\Database\Exceptions\DatabaseException: Unknown column 'db_user.country' in 'on clause'
  
  /www/codeigniter/system/Database/BaseConnection.php:647
  /www/codeigniter/system/Database/BaseBuilder.php:1800
  /www/codeigniter/system/Database/BaseBuilder.php:2561
  /www/codeigniter/tests/system/Database/Live/UpdateTest.php:405
  
  Caused by
  CodeIgniter\Database\Exceptions\DatabaseException: Unknown column 'db_user.country' in 'on clause'
  
  /www/codeigniter/system/Database/MySQLi/Connection.php:311
  /www/codeigniter/system/Database/BaseConnection.php:693
  /www/codeigniter/system/Database/BaseConnection.php:607
  /www/codeigniter/system/Database/BaseBuilder.php:1800
  /www/codeigniter/system/Database/BaseBuilder.php:2561
  /www/codeigniter/tests/system/Database/Live/UpdateTest.php:405
  
  Caused by
  mysqli_sql_exception: Unknown column 'db_user.country' in 'on clause'
  
  /www/codeigniter/system/Database/MySQLi/Connection.php:306
  /www/codeigniter/system/Database/BaseConnection.php:693
  /www/codeigniter/system/Database/BaseConnection.php:607
  /www/codeigniter/system/Database/BaseBuilder.php:1800
  /www/codeigniter/system/Database/BaseBuilder.php:2561
  /www/codeigniter/tests/system/Database/Live/UpdateTest.php:405
  
  --
  
  There were 7 failures:
  
  1) CodeIgniter\Database\Live\ForgeTest::testCreateTableWithExists
  Failed asserting that false is true.
  
  /www/codeigniter/tests/system/Database/Live/ForgeTest.php:176
  
  2) CodeIgniter\Database\Live\ForgeTest::testAddFields
  Failed asserting that two arrays are identical.
  --- Expected
  +++ Actual
  @@ @@
       0 => Array &1 (
           'name' => 'id'
           'type' => 'int'
  -        'max_length' => null
  +        'max_length' => 11
           'nullable' => false
           'default' => null
           'primary_key' => 1
  @@ @@
       3 => Array &4 (
           'name' => 'active'
           'type' => 'int'
  -        'max_length' => null
  +        'max_length' => 11
           'nullable' => false
           'default' => '0'
           'primary_key' => 0
       )
   )
  
  /www/codeigniter/tests/system/Database/Live/ForgeTest.php:1087
  
  3) CodeIgniter\Database\Live\GetVersionTest::testGetVersion
  Failed asserting that '10.11.4-MariaDB-1' matches PCRE pattern "/\A\d+(\.\d+)*\z/".
  
  /www/codeigniter/tests/system/Database/Live/GetVersionTest.php:32
  
  4) CodeIgniter\Database\Live\MetadataTest::testListTablesUnconstrainedByPrefixReturnsAllTables
  Failed asserting that two arrays are identical.
  --- Expected
  +++ Actual
  @@ @@
       5 => 'misc'
       6 => 'secondary'
       7 => 'stringifypkey'
  -    8 => 'type_test'
  -    9 => 'user'
  -    10 => 'without_auto_increment'
  -    11 => 'tmp_widgets'
  +    8 => 'test_exists'
  +    9 => 'tmp_widgets'
  +    10 => 'type_test'
  +    11 => 'user'
  +    12 => 'without_auto_increment'
   )
  
  /www/codeigniter/tests/system/Database/Live/MetadataTest.php:102
  
  5) CodeIgniter\Database\Live\MetadataTest::testListTablesConstrainedByPrefixReturnsOnlyTablesWithMatchingPrefix
  Failed asserting that two arrays are identical.
  --- Expected
  +++ Actual
  @@ @@
       5 => 'misc'
       6 => 'secondary'
       7 => 'stringifypkey'
  -    8 => 'type_test'
  -    9 => 'user'
  -    10 => 'without_auto_increment'
  +    8 => 'test_exists'
  +    9 => 'tmp_widgets'
  +    10 => 'type_test'
  +    11 => 'user'
  +    12 => 'without_auto_increment'
   )
  
  /www/codeigniter/tests/system/Database/Live/MetadataTest.php:118
  
  6) CodeIgniter\Database\Live\UpsertTest::testGetCompiledUpsert
  Failed asserting that two strings are identical.
  --- Expected
  +++ Actual
  @@ @@
  -'INSERT INTO `db_user` (`country`, `email`, `name`)
  +'INSERT INTO `user` (`country`, `email`, `name`)
   VALUES ('Iran','[email protected]','Ahmadinejad')
   ON DUPLICATE KEY UPDATE
  -`db_user`.`country` = VALUES(`country`),
  -`db_user`.`email` = VALUES(`email`),
  -`db_user`.`name` = VALUES(`name`)'
  +`user`.`country` = VALUES(`country`),
  +`user`.`email` = VALUES(`email`),
  +`user`.`name` = VALUES(`name`)'
  
  /www/codeigniter/tests/system/Database/Live/UpsertTest.php:244
  
  7) CodeIgniter\Database\Live\UpsertTest::testGetCompiledUpsertBatch
  Failed asserting that 'INSERT INTO `user` (`country`, `email`, `name`)\n
  VALUES ('Iran','[email protected]','Ahmadinejad'), ('El Salvador','[email protected]','Pedro')\n
  ON DUPLICATE KEY UPDATE\n
  `user`.`country` = VALUES(`country`),\n
  `user`.`email` = VALUES(`email`),\n
  `user`.`name` = VALUES(`name`)' contains "INSERT INTO `db_user` (`country`, `email`, `name`)".
  
  /www/codeigniter/tests/system/Database/Live/UpsertTest.php:282

Ngôn ngữ chính
PHP
Star
6k
Fork
2k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
59

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codeigniter4/CodeIgniter4

Tất cả issue của codeigniter4/CodeIgniter4

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.