Skip to content

Clear entity-manager after each task to ensure clean environment #34

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

Merged
merged 5 commits into from
Jan 18, 2017

Conversation

wachterjohannes
Copy link
Member

@@ -16,5 +16,11 @@
<argument type="string">TaskBundle:TaskExecution</argument>
</service>
<service id="task.storage.task_execution" alias="task.repository.task_execution"/>

<service id="task.event_listener.execution" class="Task\TaskBundle\EventListener\TaskExecutionListener">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this service is loaded or not should be configureable. It might be possible that the EntityManager should be cleared although the tasks are stored somewhere else.

@@ -92,6 +92,22 @@ public function findPending(TaskInterface $task)
/**
* {@inheritdoc}
*/
public function findByUuid($uuid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldnt you use the doctrine internal findOneByUuid function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh i dont like this "magic" internal methods.

@wachterjohannes wachterjohannes force-pushed the bugfix/event-after branch 4 times, most recently from 806a917 to 8471371 Compare January 11, 2017 13:47
@@ -92,6 +92,22 @@ public function findPending(TaskInterface $task)
/**
* {@inheritdoc}
*/
public function findByUuid($uuid)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same opinion as @wachterjohannes. This way it will be easier to optimize if there come up performance problem at some time.

/**
* Listens on task-execution events.
*/
class TaskExecutionListener
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be something like DoctrineTaskExecutionListener?

@wachterjohannes
Copy link
Member Author

@danrot fixed

/**
* Listens on task-execution events.
*/
class DoctrineTaskExecutionListener
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to mention that again, but I missed it the last time... Wouldn't it be better to make it a subscriber? Then it could handle all the doctrine specific settings, which might be added later. Otherwise this would have to be renamed to something to include clear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also like this we could handle everything for doctrine - i dont see the difference

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if you have to do some doctrine specific tasks on different events.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats configuration you can use multiple tags for different events.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's true, but I think it is a little bit hidden in the configuration... And since this class is already bound to an event I would also not fear implementing the EventSubscriberInterface... But well, I think that's just personal preference. It's also ok for me this way.

/**
* Listens on task-execution events.
*/
class DoctrineTaskExecutionListener
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's true, but I think it is a little bit hidden in the configuration... And since this class is already bound to an event I would also not fear implementing the EventSubscriberInterface... But well, I think that's just personal preference. It's also ok for me this way.

@@ -11,7 +11,7 @@
],
"require": {
"php": "~5.5 || ~7.0",
"php-task/php-task": "dev-master",
"php-task/php-task": "dev-bugfix/event-after",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as you've removed this change this can be merged.

@wachterjohannes
Copy link
Member Author

@danrot done

@danrot danrot merged commit 481637c into master Jan 18, 2017
@danrot danrot deleted the bugfix/event-after branch January 18, 2017 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants