Skip to content

Commit b12d5b4

Browse files
committed
fix skip mode using tablesOnly and databasesOnly
1 parent 8a68978 commit b12d5b4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/MySQLReplication/Event/Event.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ public function consume()
8686
);
8787

8888
if (ConstEventType::TABLE_MAP_EVENT === $eventInfo->getType()) {
89-
$this->eventDispatcher->dispatch(ConstEventsNames::TABLE_MAP, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeTableMapDTO());
89+
$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeTableMapDTO();
90+
if ($event !== null) {
91+
$this->eventDispatcher->dispatch(ConstEventsNames::TABLE_MAP, $event);
92+
}
9093
} else {
9194
if ([] !== $this->config->getEventsOnly() && !in_array($eventInfo->getType(), $this->config->getEventsOnly(), true)) {
9295
return;
@@ -97,11 +100,20 @@ public function consume()
97100
}
98101

99102
if (in_array($eventInfo->getType(), [ConstEventType::UPDATE_ROWS_EVENT_V1, ConstEventType::UPDATE_ROWS_EVENT_V2], true)) {
100-
$this->eventDispatcher->dispatch(ConstEventsNames::UPDATE, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeUpdateRowsDTO());
103+
$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeUpdateRowsDTO();
104+
if ($event !== null) {
105+
$this->eventDispatcher->dispatch(ConstEventsNames::UPDATE, $event);
106+
}
101107
} elseif (in_array($eventInfo->getType(), [ConstEventType::WRITE_ROWS_EVENT_V1, ConstEventType::WRITE_ROWS_EVENT_V2], true)) {
102-
$this->eventDispatcher->dispatch(ConstEventsNames::WRITE, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeWriteRowsDTO());
108+
$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeWriteRowsDTO();
109+
if ($event !== null) {
110+
$this->eventDispatcher->dispatch(ConstEventsNames::WRITE, $event);
111+
}
103112
} elseif (in_array($eventInfo->getType(), [ConstEventType::DELETE_ROWS_EVENT_V1, ConstEventType::DELETE_ROWS_EVENT_V2], true)) {
104-
$this->eventDispatcher->dispatch(ConstEventsNames::DELETE, $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeDeleteRowsDTO());
113+
$event = $this->rowEventService->makeRowEvent($binaryDataReader, $eventInfo)->makeDeleteRowsDTO();
114+
if ($event !== null) {
115+
$this->eventDispatcher->dispatch(ConstEventsNames::DELETE, $event);
116+
}
105117
} elseif (ConstEventType::XID_EVENT === $eventInfo->getType()) {
106118
$this->eventDispatcher->dispatch(ConstEventsNames::XID, (new XidEvent($eventInfo, $binaryDataReader))->makeXidDTO());
107119
} elseif (ConstEventType::ROTATE_EVENT === $eventInfo->getType()) {

0 commit comments

Comments
 (0)