-
Notifications
You must be signed in to change notification settings - Fork 103
fix #115 for mysql 8.4.0 #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi tx for contribution
1, Fix tests
- MySQLReplication\Tests\Unit\Repository\MySQLRepositoryTest::testShouldGetVersion
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'foobar123'
+''
run composer cs:fix
to fix code style
Any status of this PR or is there some other php 8.4 fixes in the works? |
My project used this pr in product env. |
…deprecated, the explicit nullable type must be used instead
@krowinski now with more mysql versions in test suite, maybe this has a chance to be tested and (maybe) merged? |
@cyppe resolve conflict pls |
tests are failing There were 2 failures:
/home/runner/work/php-mysql-replication/php-mysql-replication/tests/Unit/BinaryDataReader/BinaryDataReaderTest.php:138
/home/runner/work/php-mysql-replication/php-mysql-replication/tests/Unit/BinaryDataReader/BinaryDataReaderTest.php:190 FAILURES! |
Because I change return value of Int64 type like default PDO::ATTR_STRINGIFY_FETCHES=false OR MYSQLI_OPT_INT_AND_FLOAT_NATIVE , Int64 may string or int value. CREATE TABLE `test` (
`id` bigint unsigned NOT NULL DEFAULT '0',
`show` int DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
insert into test(id) values(9223372036854775807),(9223372036854775808); try {
// 数据库配置
$host = '127.0.0.1';
$db = 'test'; // 你的数据库名
$user = 'root'; // 数据库用户名
$pass = ''; // 数据库密码
$port = "3306";
$charset = 'utf8mb4';
// 设置DSN(数据源名称)
$dsn = "mysql:host=$host;dbname=$db;charset=$charset;port=$port";
// 设置PDO选项
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // 抛出异常错误
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, // 获取关联数组
PDO::ATTR_EMULATE_PREPARES => false, // 关闭模拟预处理
];
// 创建PDO实例
$pdo = new PDO($dsn, $user, $pass, $options);
// 编写SQL语句
$sql = "SELECT * FROM test"; // 假设你有一个users表
var_dump(PHP_INT_MAX);
var_dump(PHP_INT_MIN);
// 执行查询
$stmt = $pdo->query($sql);
// 获取结果
while ($row = $stmt->fetch()) {
var_dump($row);
}
} catch (\PDOException $e) {
// 处理连接错误
throw new \PDOException($e->getMessage(), (int)$e->getCode());
} |
if($num>PHP_INT_MAX || $num<PHP_INT_MIN){ | ||
return $num; | ||
}else{ | ||
return intval($num); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its better to return always string here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you are really close to getting this done, @krowinski maybe you can be the tie breaker and just say how you want it to get this rolling? Would be awesome to get Mysql 8.4 support rolling.
$num = bcadd((string)$data[1], (string)($data[2] << 32)); | ||
if($num>PHP_INT_MAX || $num<PHP_INT_MIN){ | ||
return $num; | ||
}else{ | ||
return intval($num); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
At present, the main problem is that there are some problems with the test cases in tests. I have taken a look at it and it is quite complicated. I would like to ask you to solve it~~ |
…Int64 - Changed readInt64() to always return string instead of string|int - Changed unpackUInt64() to always return string instead of string|int - Changed readUInt64() return type to string for consistency - Applied code style fixes with composer cs:fix - Fixes failing tests: testShouldReadInt64 and testShouldPack64bit Addresses maintainer feedback from PR krowinski#116 regarding MySQL 8.4.0 compatibility.
* fix #115 for mysql 8.0.0 * fix #115 for mysql 8.4.0 * fix #115 for mysql 8.4.0 phpunit test * fix issue #125 * change to hetao29 * Fix PHP 8.4 deprecation: Implicitly marking parameter as nullable is deprecated, the explicit nullable type must be used instead * change to krowinski * Fix maintainer feedback: always return strings from readInt64/unpackUInt64 - Changed readInt64() to always return string instead of string|int - Changed unpackUInt64() to always return string instead of string|int - Changed readUInt64() return type to string for consistency - Applied code style fixes with composer cs:fix - Fixes failing tests: testShouldReadInt64 and testShouldPack64bit Addresses maintainer feedback from PR #116 regarding MySQL 8.4.0 compatibility. * Fix DBAL 4.x compatibility issue in testShouldReconnect In DBAL 4.x, Doctrine\DBAL\Exception became an interface instead of a concrete class. The test was trying to instantiate 'new Exception('')' which fails with 'Cannot instantiate interface Doctrine\DBAL\Exception'. Fixed by using ConnectionException mock which implements the Exception interface, preserving the exact same test logic and coverage as the original DBAL 3.x version. * Fix MySQLRepository for DBAL 4.x compatibility Remove manual connection reconnection logic since DBAL 4.x handles reconnection automatically. The connect() method became protected in DBAL 4.x, causing 'Call to protected method' errors. Changes: - Removed manual ping/close/connect logic from getConnection() - DBAL 4.x automatically handles lost connections and reconnection - Kept ping() method as required by PingableConnection interface This fixes the repository to work with DBAL 4.x while maintaining the same functionality. --------- Co-authored-by: hetao <hetao@hetao.name> Co-authored-by: HeTao <8010298+hetao29@users.noreply.github.com>
No description provided.