diff --git a/composer.json b/composer.json index cae9b1c..99c1f74 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "ext-json": "*", "ext-sockets": "*", "doctrine/collections": "^2.1", - "doctrine/dbal": "^3.8", + "doctrine/dbal": "^4.0", "psr/log": "^3.0", "psr/simple-cache": "^3.0", "symfony/event-dispatcher": "^6.0|^7.0" @@ -26,7 +26,7 @@ "kubawerlos/php-cs-fixer-custom-fixers": "^3.19", "monolog/monolog": "^3.5", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.5", + "phpunit/phpunit": "^11.0", "symplify/easy-coding-standard": "^12.1" }, "license": "MIT", diff --git a/src/MySQLReplication/BinaryDataReader/BinaryDataReader.php b/src/MySQLReplication/BinaryDataReader/BinaryDataReader.php index 3a8119f..ca521ee 100644 --- a/src/MySQLReplication/BinaryDataReader/BinaryDataReader.php +++ b/src/MySQLReplication/BinaryDataReader/BinaryDataReader.php @@ -114,16 +114,21 @@ public function readUInt24(): int return $data[1] + ($data[2] << 8) + ($data[3] << 16); } - public function readUInt64(): string + public function readUInt64(): string|int { return $this->unpackUInt64($this->read(self::UNSIGNED_INT64_LENGTH)); } - public function unpackUInt64(string $binary): string + public function unpackUInt64(string $binary): string|int { $data = self::unpack('V*', $binary); - return bcadd((string)$data[1], bcmul((string)$data[2], bcpow('2', '32'))); + $num = bcadd((string)$data[1], bcmul((string)$data[2], bcpow('2', '32'))); + if($num>PHP_INT_MAX || $numread(self::UNSIGNED_INT64_LENGTH)); - return bcadd((string)$data[1], (string)($data[2] << 32)); + $num = bcadd((string)$data[1], (string)($data[2] << 32)); + if($num>PHP_INT_MAX || $numunpackUInt64($this->read(self::UNSIGNED_INT48_LENGTH) . chr(0) . chr(0)); + return (string)$this->unpackUInt64($this->read(self::UNSIGNED_INT48_LENGTH) . chr(0) . chr(0)); } public function isComplete(int $size): bool diff --git a/src/MySQLReplication/Event/RotateEvent.php b/src/MySQLReplication/Event/RotateEvent.php index 0e0d2b9..58f3118 100644 --- a/src/MySQLReplication/Event/RotateEvent.php +++ b/src/MySQLReplication/Event/RotateEvent.php @@ -13,7 +13,7 @@ class RotateEvent extends EventCommon { public function makeRotateEventDTO(): RotateDTO { - $binFilePos = $this->binaryDataReader->readUInt64(); + $binFilePos = (string)$this->binaryDataReader->readUInt64(); $binFileName = $this->binaryDataReader->read( $this->eventInfo->getSizeNoHeader() - $this->getSizeToRemoveByVersion() ); diff --git a/src/MySQLReplication/Event/RowEvent/RowEvent.php b/src/MySQLReplication/Event/RowEvent/RowEvent.php index 66d04af..60bc24c 100644 --- a/src/MySQLReplication/Event/RowEvent/RowEvent.php +++ b/src/MySQLReplication/Event/RowEvent/RowEvent.php @@ -416,7 +416,7 @@ public function makeUpdateRowsDTO(): ?UpdateRowsDTO protected function findTableMap(): ?TableMap { - $tableId = $this->binaryDataReader->readTableId(); + $tableId = (string)$this->binaryDataReader->readTableId(); $this->binaryDataReader->advance(2); if (in_array( diff --git a/src/MySQLReplication/Event/XidEvent.php b/src/MySQLReplication/Event/XidEvent.php index 39611fa..a59f981 100644 --- a/src/MySQLReplication/Event/XidEvent.php +++ b/src/MySQLReplication/Event/XidEvent.php @@ -13,6 +13,6 @@ class XidEvent extends EventCommon { public function makeXidDTO(): XidDTO { - return new XidDTO($this->eventInfo, $this->binaryDataReader->readUInt64()); + return new XidDTO($this->eventInfo, (string)$this->binaryDataReader->readUInt64()); } }