File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 11<?php
22namespace MySQLReplication \BinLog ;
33
4+ use MySQLReplication \BinaryDataReader \BinaryDataReader ;
45use MySQLReplication \BinLog \Exception \BinLogException ;
56use MySQLReplication \Config \Config ;
67use MySQLReplication \Repository \MySQLRepository ;
@@ -253,7 +254,7 @@ private function getBinlogStream()
253254 $ prelude .= chr (0 );
254255 $ prelude .= chr (0 );
255256 $ prelude .= chr (0 );
256- $ prelude .= pack ( ' Q ' , 4 );
257+ $ prelude .= BinaryDataReader:: pack64bit ( 4 );
257258
258259 $ prelude .= pack ('I ' , $ this ->gtidCollection ->getEncodedLength ());
259260 $ prelude .= $ this ->gtidCollection ->getEncoded ();
Original file line number Diff line number Diff line change @@ -417,4 +417,22 @@ public function isComplete($size)
417417 }
418418 return true ;
419419 }
420+
421+ /**
422+ * @param int $value
423+ * @return string
424+ */
425+ public static function pack64bit ($ value )
426+ {
427+ return pack ('C8 ' ,
428+ ($ value >> 0 ) & 0xFF ,
429+ ($ value >> 8 ) & 0xFF ,
430+ ($ value >> 16 ) & 0xFF ,
431+ ($ value >> 24 ) & 0xFF ,
432+ ($ value >> 32 ) & 0xFF ,
433+ ($ value >> 40 ) & 0xFF ,
434+ ($ value >> 48 ) & 0xFF ,
435+ ($ value >> 56 ) & 0xFF
436+ );
437+ }
420438}
Original file line number Diff line number Diff line change 22
33namespace MySQLReplication \Gtid ;
44
5+ use MySQLReplication \BinaryDataReader \BinaryDataReader ;
6+
57/**
68 * Class Gtid
79 * @package MySQLReplication\Gtid
@@ -43,19 +45,19 @@ public function __construct($gtid)
4345 public function getEncoded ()
4446 {
4547 $ buffer = pack ('H* ' , $ this ->sid );
46- $ buffer .= pack ( ' Q ' , count ($ this ->intervals ));
48+ $ buffer .= BinaryDataReader:: pack64bit ( count ($ this ->intervals ));
4749
4850 foreach ($ this ->intervals as $ interval )
4951 {
5052 if (count ($ interval ) != 1 )
5153 {
52- $ buffer .= pack ( ' Q ' , $ interval [0 ]);
53- $ buffer .= pack ( ' Q ' , $ interval [1 ]);
54+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [0 ]);
55+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [1 ]);
5456 }
5557 else
5658 {
57- $ buffer .= pack ( ' Q ' , $ interval [0 ]);
58- $ buffer .= pack ( ' Q ' , $ interval [0 ] + 1 );
59+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [0 ]);
60+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [0 ] + 1 );
5961 }
6062 }
6163
Original file line number Diff line number Diff line change 33namespace MySQLReplication \Gtid ;
44
55use Doctrine \Common \Collections \ArrayCollection ;
6+ use MySQLReplication \BinaryDataReader \BinaryDataReader ;
67
78/**
89 * Class GtidSet
@@ -29,7 +30,7 @@ public function getEncodedLength()
2930 */
3031 public function getEncoded ()
3132 {
32- $ s = pack ( ' Q ' , $ this ->count ());
33+ $ s = BinaryDataReader:: pack64bit ( $ this ->count ());
3334 /** @var Gtid $gtid */
3435 foreach ($ this ->toArray () as $ gtid )
3536 {
You can’t perform that action at this time.
0 commit comments