Add support for php-mysql-replication v9.0.0 + fix table-specific event routing#21
Conversation
📝 WalkthroughWalkthroughUpdates dependency constraint for krowinski/php-mysql-replication and changes event handling and CLI start command: Trigger::dispatch now uses an instanceof RowsDTO and reads tableMap properties; StartCommand adds signal handlers (SIGTERM/SIGINT) and a typed return for handle(). Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.38)At least one path must be specified to analyse. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
src/Console/StartCommand.php
Outdated
| pcntl_signal(SIGTERM, function () { | ||
| $this->info('Received SIGTERM, shutting down...'); | ||
| $this->shouldTerminate = true; | ||
| }); | ||
|
|
||
| pcntl_signal(SIGINT, function () { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
8ce5e5b to
6607b19
Compare
Summary
krowinski/php-mysql-replicationconstraint from^8.0to^8.0 || ^9.0Trigger::dispatch()where table-specific event routing never actually workedThe bug
The
dispatch()method checks if the event has a table map usingis_callable([$event, 'getTableMap']), then calls$event->getTableMap()->getDatabase()and->getTable(). The problem is these getter methods don't exist in v8.x (or v9.0.0) -- both versions use public readonly properties onTableMap(->database,->table).Because
is_callablesilently returnsfalse, the entire block is skipped. This means any route registered with a specific table (e.g.$trigger->on('mydb.users', 'write', ...)) never fires. Only wildcard routes (*.*.*) work.Fix
Replaced the broken callable check with
$event instanceof RowsDTOand access the properties directly:Why v9.0.0 works without other changes
The public API surface consumed by laravel-trigger (
EventDTO,RowsDTO,TableMap,ConfigBuilder,BinLogCurrent,EventSubscribers, etc.) is identical between v8.x and v9.0.0. No other files need changes.Summary by CodeRabbit
Chores
Refactor
New Features