Skip to content

Calling $this->repository->get for the same AR twice will not find recorded events on the first result. #179

Description

@basz

Use case:

I'm trying to use the user AR's as an identity for my permission checks. By coincidence I started to add permissions to the UserAR. For other AR's then Users this problem wouldn't surface.

https://gist.github.com/basz/86942655f534c34f984b5d43f0d79f66#file-gistfile1-txt-L65-L73

Digging into this I believe it happens because calling repo->get will always rebuild a new object and return that. Loosing events recorded on the first.

https://github.com/prooph/event-store/blob/master/src/Aggregate/AggregateRepository.php#L162

Is there a reason the repository doesn't return the cached version if it is available? Would it be bad if we add that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions