prooph / pdo-event-store

PDO implementation of ProophEventStore http://getprooph.org
BSD 3-Clause "New" or "Revised" License
111 stars 56 forks source link

Projections (v7) with '->when(event)' won't persist the position until a registered event handler is called #203

Closed basz closed 5 years ago

basz commented 5 years ago

Given

Looking at the code for that method it does not increment the processed events ($this->eventCounter) until it encounters a registered message handler. Therefore the position of 'streamed' events will not be persisted until a registered message handler is encountered.

I believe this is not very problematic except for process managers and unless you stop the projection and change the registered handlers and restart the projection. The projection will then start processing events that were created before the code change, which is probably not what you would want for process managers.

The fix is I believe to invert these two statements? https://github.com/prooph/pdo-event-store/blob/master/src/Projection/PdoEventStoreProjector.php#L653-L657 Thus always increment any processed events regardless if they have a handler registered.

I hope this explanation is clear... :-/