From b12d5b4b5524b0f764a872314448194a9358deb5 Mon Sep 17 00:00:00 2001 From: "gilwon.oh" Date: Thu, 17 Nov 2016 17:55:10 +0900 Subject: [PATCH] fix skip mode using tablesOnly and databasesOnly --- src/MySQLReplication/Event/Event.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/MySQLReplication/Event/Event.php b/src/MySQLReplication/Event/Event.php index c99947e..dde632d 100644 --- a/src/MySQLReplication/Event/Event.php +++ b/src/MySQLReplication/Event/Event.php @@ -86,7 +86,10 @@ public function consume() ); if (ConstEventType::TABLE_MAP_EVENT === $eventInfo->getType()) { - $this->eventDispatcher->dispatch(ConstEventsNames::TABLE_MAP, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeTableMapDTO()); + $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeTableMapDTO(); + if ($event !== null) { + $this->eventDispatcher->dispatch(ConstEventsNames::TABLE_MAP, $event); + } } else { if ([] !== $this->config->getEventsOnly() && !in_array($eventInfo->getType(), $this->config->getEventsOnly(), true)) { return; @@ -97,11 +100,20 @@ public function consume() } if (in_array($eventInfo->getType(), [ConstEventType::UPDATE_ROWS_EVENT_V1, ConstEventType::UPDATE_ROWS_EVENT_V2], true)) { - $this->eventDispatcher->dispatch(ConstEventsNames::UPDATE, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeUpdateRowsDTO()); + $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeUpdateRowsDTO(); + if ($event !== null) { + $this->eventDispatcher->dispatch(ConstEventsNames::UPDATE, $event); + } } elseif (in_array($eventInfo->getType(), [ConstEventType::WRITE_ROWS_EVENT_V1, ConstEventType::WRITE_ROWS_EVENT_V2], true)) { - $this->eventDispatcher->dispatch(ConstEventsNames::WRITE, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeWriteRowsDTO()); + $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeWriteRowsDTO(); + if ($event !== null) { + $this->eventDispatcher->dispatch(ConstEventsNames::WRITE, $event); + } } elseif (in_array($eventInfo->getType(), [ConstEventType::DELETE_ROWS_EVENT_V1, ConstEventType::DELETE_ROWS_EVENT_V2], true)) { - $this->eventDispatcher->dispatch(ConstEventsNames::DELETE, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeDeleteRowsDTO()); + $event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeDeleteRowsDTO(); + if ($event !== null) { + $this->eventDispatcher->dispatch(ConstEventsNames::DELETE, $event); + } } elseif (ConstEventType::XID_EVENT === $eventInfo->getType()) { $this->eventDispatcher->dispatch(ConstEventsNames::XID, (new XidEvent($eventInfo, $binaryDataReader))->makeXidDTO()); } elseif (ConstEventType::ROTATE_EVENT === $eventInfo->getType()) {