stephpy / timeline-bundle

Symfony2 bundle to make timeline
193 stars 57 forks source link

Component data is empty with `delivery: wait` config option #188

Closed berdyshev closed 9 years ago

berdyshev commented 9 years ago

Hi.

I have empty database. Spread delivery set to wait and filter_unresolved set to true. When I run the doctrine:fixtures:load command to populate content, timeline actions also created for corresponding event (like following some entity, new post etc). But when I'm running after that spy_timeline:deploy command, I'm getting fatal error in my spread class — $action->getComponent('complement')->getData() returns NULL.

But when user performs some actions on the site after that (I commented delivery: wait config), all works fine — timeline actions are delivered correctly.

I can't understand why component data is NULL in spread class with config delivery: wait. Do you have any thoughts on this point?

stephpy commented 9 years ago

Hi,

Filter (DataHydrator) does not work in Spread classes. I never had this use case but you have to manually call DataHydrator or manually fetch entities.

berdyshev commented 9 years ago

Sorry, but why my case is special, so delivery: wait option doesn't work for me? Is this not a typical use case when I don't spread actions immediately, but using command spy_timeline:deploy via cron, for example. For which cases this option should be used and how it works then?

stephpy commented 9 years ago

Hi,

As I said

you have to manually call DataHydrator or manually fetch entities.

In spread class.

berdyshev commented 9 years ago

Sorry, but I can't understand the logic. As I understand, option delivery: wait should have only one difference in the bundle's workflow: after some event occurred actions are delivered not immediately, but demand of console command spy_timeline:deploy. That's all, imho! Spreading logic shouldn't depend on delivery type!

But as I'm understanding you replies, I should have different implementations of spread class for this two cases (immediate and deferred delivery of events). That's sounds weird. I think this is some kind of bug. Isn't it?

stephpy commented 9 years ago

It's not kind of bug. It's written nowhere but in a spread class, you SHOULD NOT use components of the action which is spread.

If you use components of this action, on delivery immediate, theses components are already defined and instanciated ... On delivery wait, action is fetched from database and components aren't hydrated. That's the current issue.

I would have one advice ... It's to not use components of the action in spread classes.

berdyshev commented 9 years ago

Thank you Stéphane.

I thought that is common case to use components in spread, because usually (at least in my case) the users, which should receive certain events, depend on those components. For example, friends of the post author, "members" of some entity, etc.

stephpy commented 9 years ago

I see, but you could fetch this component from your database instead of using action->getComponent.

Else we would have to use DataHydrator in spread when delivery: wait and it's not useful in all cases to hydrate components of actions. IMO it's specific and the only one error done is to pass a full action object where you can get component data. You should fetch this data from database, by this way, you'll be able to pass from delivery wait to immediate without any problem.

berdyshev commented 9 years ago

Thanks. Added manual entity loading in spread class.