Skip to content

Commit 2487f91

Browse files
committed
## v5.0.0 (2018-04-27)
- Removed unused classes from code and merged some classes to one class - Added ability in MySQLReplicationFactory to provide implementations interfaces in constructor. This will give ability to replace default classes to your own - Added Config to MySQLReplicationFactory constructor (#35) - Changed register subscriber to accept interface of EventSubscriberInterface over EventSubscribers class (#36) - Changed moved exception messages to main exception class - Changed psr-2 "elseif " replaced to "else if" - Fixed 5.7 json column deserialization for null value + tests - Changed minor refactoring in classes
1 parent 80ac3a9 commit 2487f91

38 files changed

+679
-700
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
# Release Notes
44

5+
## v5.0.0 (2018-04-27)
6+
- Removed unused classes from code and merged some classes to one class
7+
- Added ability in MySQLReplicationFactory to provide implementations interfaces in constructor. This will give ability to replace default classes to your own
8+
- Added Config to MySQLReplicationFactory constructor (#35)
9+
- Changed register subscriber to accept interface of EventSubscriberInterface over EventSubscribers class (#36)
10+
- Changed moved exception messages to main exception class
11+
- Changed psr-2 "elseif " replaced to "else if"
12+
- Fixed 5.7 json column deserialization for null value + tests
13+
- Changed minor refactoring in classes
14+
515
## v4.0.0 (2018-03-10)
616
- Removed unused (probably?) classes ConfigService, BinaryDataReaderService
717
- Changed Event class broke into smaller methods to be cleaner

src/MySQLReplication/BinLog/BinLogAuth.php

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/MySQLReplication/BinLog/BinLogSocketConnect.php

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use MySQLReplication\BinaryDataReader\BinaryDataReader;
66
use MySQLReplication\Config\Config;
7-
use MySQLReplication\Definitions\ConstCapabilityFlags;
8-
use MySQLReplication\Definitions\ConstCommand;
97
use MySQLReplication\Exception\MySQLReplicationException;
108
use MySQLReplication\Gtid\GtidException;
119
use MySQLReplication\Gtid\GtidFactory;
@@ -18,6 +16,10 @@
1816
*/
1917
class BinLogSocketConnect
2018
{
19+
const COM_BINLOG_DUMP = 0x12;
20+
const COM_REGISTER_SLAVE = 0x15;
21+
const COM_BINLOG_DUMP_GTID = 0x1e;
22+
2123
/**
2224
* @var bool
2325
*/
@@ -114,7 +116,7 @@ private function isWriteSuccessful($data)
114116
*/
115117
private function authenticate()
116118
{
117-
$data = pack('L', ConstCapabilityFlags::getCapabilities());
119+
$data = pack('L', self::getCapabilities());
118120
$data .= pack('L', $this->binaryDataMaxLength);
119121
$data .= chr(33);
120122
for ($i = 0; $i < 23; $i++) {
@@ -133,6 +135,38 @@ private function authenticate()
133135
$this->getResponse();
134136
}
135137

138+
/**
139+
* http://dev.mysql.com/doc/internals/en/capability-flags.html#packet-protocol::capabilityflags
140+
* https://github.com/siddontang/mixer/blob/master/doc/protocol.txt
141+
* @return int
142+
*/
143+
private static function getCapabilities()
144+
{
145+
/*
146+
Left only as information
147+
$foundRows = 1 << 1;
148+
$connectWithDb = 1 << 3;
149+
$compress = 1 << 5;
150+
$odbc = 1 << 6;
151+
$localFiles = 1 << 7;
152+
$ignoreSpace = 1 << 8;
153+
$multiStatements = 1 << 16;
154+
$multiResults = 1 << 17;
155+
$interactive = 1 << 10;
156+
$ssl = 1 << 11;
157+
$ignoreSigPipe = 1 << 12;
158+
*/
159+
160+
$noSchema = 1 << 4;
161+
$longPassword = 1;
162+
$longFlag = 1 << 2;
163+
$transactions = 1 << 13;
164+
$secureConnection = 1 << 15;
165+
$protocol41 = 1 << 9;
166+
167+
return ($longPassword | $longFlag | $transactions | $protocol41 | $secureConnection | $noSchema);
168+
}
169+
136170
/**
137171
* @throws BinLogException
138172
* @throws GtidException
@@ -186,7 +220,7 @@ private function registerSlave()
186220
$passLength = strlen(Config::getPassword());
187221

188222
$data = pack('l', 18 + $hostLength + $userLength + $passLength);
189-
$data .= chr(ConstCommand::COM_REGISTER_SLAVE);
223+
$data .= chr(self::COM_REGISTER_SLAVE);
190224
$data .= pack('V', Config::getSlaveId());
191225
$data .= pack('C', $hostLength);
192226
$data .= $host;
@@ -226,7 +260,7 @@ private function setBinLogDumpGtid()
226260
{
227261
$collection = GtidFactory::makeCollectionFromString(Config::getGtid());
228262

229-
$data = pack('l', 26 + $collection->getEncodedLength()) . chr(ConstCommand::COM_BINLOG_DUMP_GTID);
263+
$data = pack('l', 26 + $collection->getEncodedLength()) . chr(self::COM_BINLOG_DUMP_GTID);
230264
$data .= pack('S', 0);
231265
$data .= pack('I', Config::getSlaveId());
232266
$data .= pack('I', 3);
@@ -264,7 +298,7 @@ private function setBinLogDump()
264298
$binFileName = $master['File'];
265299
}
266300

267-
$data = pack('i', strlen($binFileName) + 11) . chr(ConstCommand::COM_BINLOG_DUMP);
301+
$data = pack('i', strlen($binFileName) + 11) . chr(self::COM_BINLOG_DUMP);
268302
$data .= pack('I', $binFilePos);
269303
$data .= pack('v', 0);
270304
$data .= pack('I', Config::getSlaveId());

src/MySQLReplication/BinLog/BinLogSocketConnectInterface.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/MySQLReplication/BinLog/Exception/BinLogException.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/MySQLReplication/BinaryDataReader/BinaryDataReader.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public function advance($length)
5454
/**
5555
* @param int $length
5656
* @return string
57-
* @throws BinaryDataReaderException
5857
*/
5958
public function read($length)
6059
{
@@ -67,7 +66,6 @@ public function read($length)
6766

6867
/**
6968
* @return int
70-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
7169
*/
7270
public function readInt16()
7371
{
@@ -118,7 +116,6 @@ public function readCodedBinary()
118116

119117
/**
120118
* @return int
121-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
122119
*/
123120
public function readUInt16()
124121
{
@@ -127,7 +124,6 @@ public function readUInt16()
127124

128125
/**
129126
* @return int
130-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
131127
*/
132128
public function readUInt24()
133129
{
@@ -138,7 +134,6 @@ public function readUInt24()
138134

139135
/**
140136
* @return string
141-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
142137
*/
143138
public function readUInt64()
144139
{
@@ -158,7 +153,6 @@ public function unpackUInt64($binary)
158153

159154
/**
160155
* @return int
161-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
162156
*/
163157
public function readInt24()
164158
{
@@ -174,7 +168,6 @@ public function readInt24()
174168

175169
/**
176170
* @return string
177-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
178171
*/
179172
public function readInt64()
180173
{
@@ -231,7 +224,6 @@ public function readUIntBySize($size)
231224

232225
/**
233226
* @return int
234-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
235227
*/
236228
public function readUInt8()
237229
{
@@ -240,7 +232,6 @@ public function readUInt8()
240232

241233
/**
242234
* @return int
243-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
244235
*/
245236
public function readUInt32()
246237
{
@@ -249,7 +240,6 @@ public function readUInt32()
249240

250241
/**
251242
* @return mixed
252-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
253243
*/
254244
public function readUInt40()
255245
{
@@ -261,7 +251,6 @@ public function readUInt40()
261251

262252
/**
263253
* @return mixed
264-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
265254
*/
266255
public function readUInt48()
267256
{
@@ -272,7 +261,6 @@ public function readUInt48()
272261

273262
/**
274263
* @return mixed
275-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
276264
*/
277265
public function readUInt56()
278266
{
@@ -312,7 +300,6 @@ public function readIntBeBySize($size)
312300

313301
/**
314302
* @return int
315-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
316303
*/
317304
public function readInt8()
318305
{
@@ -321,7 +308,6 @@ public function readInt8()
321308

322309
/**
323310
* @return mixed
324-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
325311
*/
326312
public function readInt16Be()
327313
{
@@ -330,7 +316,6 @@ public function readInt16Be()
330316

331317
/**
332318
* @return int
333-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
334319
*/
335320
public function readInt24Be()
336321
{
@@ -345,7 +330,6 @@ public function readInt24Be()
345330

346331
/**
347332
* @return int
348-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
349333
*/
350334
public function readInt32Be()
351335
{
@@ -354,7 +338,6 @@ public function readInt32Be()
354338

355339
/**
356340
* @return int
357-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
358341
*/
359342
public function readInt40Be()
360343
{
@@ -366,7 +349,6 @@ public function readInt40Be()
366349

367350
/**
368351
* @return int
369-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
370352
*/
371353
public function readInt32()
372354
{
@@ -375,7 +357,6 @@ public function readInt32()
375357

376358
/**
377359
* @return float
378-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
379360
*/
380361
public function readFloat()
381362
{
@@ -384,7 +365,6 @@ public function readFloat()
384365

385366
/**
386367
* @return double
387-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
388368
*/
389369
public function readDouble()
390370
{
@@ -393,7 +373,6 @@ public function readDouble()
393373

394374
/**
395375
* @return string
396-
* @throws \MySQLReplication\BinaryDataReader\BinaryDataReaderException
397376
*/
398377
public function readTableId()
399378
{

0 commit comments

Comments
 (0)