Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flush in save() method should be limited to just that entity #12

Open
tacman opened this issue Nov 2, 2017 · 6 comments
Open

flush in save() method should be limited to just that entity #12

tacman opened this issue Nov 2, 2017 · 6 comments

Comments

@tacman
Copy link

tacman commented Nov 2, 2017

The global flush of the entity manger is unnecessary and problematic -- only the link itself should be persisted to the database. I'll add a PR for this.

@mremi
Copy link
Owner

mremi commented Nov 2, 2017

Hi @tacman ,

Can you explain your use case to have history about that please?

@tacman
Copy link
Author

tacman commented Nov 2, 2017

We're using the bundle to create a list of links during our testing, and in the process of doing that we're creating entities that we don't want persisted. Alas, some of those entities are tagged in Doctrine as having automatic persistence, which isn't a big deal, since we simply don't flush the entity manager at the end.

So the problem now is that if we use the bundle to create a short URL, it's calling flush() and saving those entities to the database. We want the link flushed, but nothing else.

@tacman
Copy link
Author

tacman commented Nov 2, 2017 via email

@mremi
Copy link
Owner

mremi commented Nov 2, 2017

I think it will be more logical to flush only the given entity instead of adding a $flush argument to the Twig helpers.

@tacman
Copy link
Author

tacman commented Nov 3, 2017

Agreed. The only downside is that flush shouldn't be inside a loop, but that's an edge case. But the save method definitely should not be flushing entities outside the scope of the bundle. Is my PR okay? Alas, I'm not familiar enough with writing tests to do so. Obviously, it's a really tiny change.

@mremi
Copy link
Owner

mremi commented Nov 3, 2017

Let's go to #13 to validate the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants