stephpy/timeline-bundle

getTimeline returns nothing

Closed this issue · 16 comments

Hi,

I've just tested this bundle with this configuration:

  • Symfony 3.3.10
  • Redis Server 3.0.7 (MacBook Air)
  • PHP 7.0.20
  • "stephpy/timeline-bundle": "2.4.*",
  • "snc/redis-bundle": "2.0.*",
  • "predis/predis": "1.1.*"
$actionManager = $this->get('spy_timeline.action_manager');
$timelineManager = $this->get('spy_timeline.timeline_manager');

$subject       = $actionManager->findOrCreateComponent('a\model', array(1, 2));

$action = $actionManager->create($subject, 'verb', array('directComplement' => 'foo'));
$actionManager->updateAction($action);

$timeline = $timelineManager->getTimeline($subject);
dump($timeline);

The dump command returns "[]" :(

In the devtoolbar, panel Redis, there are 5 items :

1 | 3.09 ms | default | HLEN astro:action
2 | 2.30 ms | default | HSET astro:action 1 O:25:"Spy\Timeline\Model\Action":10:{s:5:"*id";i:1;s:7:"*verb";s:4:"verb";s:16:"*statusCurrent";s:7:"pending";s:15:"*statusWanted";s:9:"published";s:15:"*duplicateKey";N;s:20:"*duplicatePriority";N;s:13:"*duplicated";b:0;s:12:"*createdAt";O:8:"DateTime":3:{s:4:"date";s:26:"2017-10-19 09:38:29.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Berlin";}s:19:"*actionComponents";a:2:{i:0;O:34:"Spy\Timeline\Model\ActionComponent":5:{s:5:"*id";N;s:7:"*type";s:16:"directComplement";s:7:"*text";s:4:"toto";s:9:"*action";r:1;s:12:"*component";N;}i:1;O:34:"Spy\Timeline\Model\ActionComponent":5:{s:5:"*id";N;s:7:"*type";s:7:"subject";s:7:"*text";N;s:9:"*action";r:1;s:12:"*component";O:28:"Spy\Timeline\Model\Component":4:{s:5:"*id";N;s:8:"*model";s:7:"a\model";s:13:"*identifier";a:2:{i:0;i:1;i:1;i:2;}s:7:"*hash";s:30:"a\model#a:2:{i:0;i:1;i:1;i:2;}";}}}s:12:"*timelines";a:0:{}}
3 | 0.23 ms | default | HLEN astro:action
4 | 0.24 ms | default | HSET astro:action 2 O:25:"Spy\Timeline\Model\Action":10:{s:5:"*id";i:2;s:7:"*verb";s:4:"verb";s:16:"*statusCurrent";s:9:"published";s:15:"*statusWanted";s:6:"frozen";s:15:"*duplicateKey";N;s:20:"*duplicatePriority";N;s:13:"*duplicated";b:0;s:12:"*createdAt";O:8:"DateTime":3:{s:4:"date";s:26:"2017-10-19 09:38:29.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Berlin";}s:19:"*actionComponents";a:2:{i:0;O:34:"Spy\Timeline\Model\ActionComponent":5:{s:5:"*id";N;s:7:"*type";s:16:"directComplement";s:7:"*text";s:4:"toto";s:9:"*action";r:1;s:12:"*component";N;}i:1;O:34:"Spy\Timeline\Model\ActionComponent":5:{s:5:"*id";N;s:7:"*type";s:7:"subject";s:7:"*text";N;s:9:"*action";r:1;s:12:"*component";O:28:"Spy\Timeline\Model\Component":4:{s:5:"*id";N;s:8:"*model";s:7:"a\model";s:13:"*identifier";a:2:{i:0;i:1;i:1;i:2;}s:7:"*hash";s:30:"a\model#a:2:{i:0;i:1;i:1;i:2;}";}}}s:12:"*timelines";a:0:{}}
5 | 0.66 ms | default | ZREVRANGE astro:a\model#a:2:{i:0;i:1;i:1;i:2;}:GLOBAL:timeline 0 9

What is wrong ?

Hi,

Do you have DataHydrator filter activated ? doc

No. Here is my config.yml :

spy_timeline:
    drivers:
        redis:
            client: snc_redis.default
            prefix: astro

snc_redis:
    clients:
        default:
            type: predis
            alias: default
            dsn: redis://localhost

I think you are missing the filter part for the configuration.

this is how i configured mine for mongodb.

spy_timeline:
    drivers:
        odm:
            object_manager: doctrine.odm.mongodb.document_manager
            classes:
                timeline:         AppBundle\Document\Timeline\Timeline
                action:           AppBundle\Document\Timeline\Action
                component:        AppBundle\Document\Timeline\Component
                action_component: AppBundle\Document\Timeline\ActionComponent

    notifiers:
        - spy_timeline.unread_notifications

    filters:
        duplicate_key:
            priority: 10
        data_hydrator:
            priority: 20
            filter_unresolved: false
            locators:
                - spy_timeline.filter.data_hydrator.locator.doctrine_odm

Hum... I did not understand something

In your example $subject = $actionManager->findOrCreateComponent('a\model', array(1, 2));, a\model (1,2) is the "key" for the Redis entry ?

Does this key need to be mapped with an Doctrine Entity with the hydrator ?

Can you try to add

    filters:
        data_hydrator:
            filter_unresolved: false

to your config ?
Just to be sure it's not due to the data_hydrator resolver ?

I add filter_unresolved: false in my config.yml but the result is the same.

PS: the bundle on a other project, with Symfony2.7, works fine.

I have made some tests with a fresh Symfony install : Symfony 2.8.28 (Redis works fine on this version on a personal project). For the same PHP example code mentioned above :

Works fine :

"stephpy/timeline-bundle": "2.4.*",
"snc/redis-bundle": "1.1.8",
"predis/predis": "0.8.*"

Not working :

"stephpy/timeline-bundle": "2.4.*",
"snc/redis-bundle": "1.1.9",
"predis/predis": "~1.0"

Not working :

"stephpy/timeline-bundle": "2.4.*",
"snc/redis-bundle": "2.*",
"predis/predis": "1.0.*"

Ok, sorry for delay,

It seems predis or snc/redis-bundle (I think it's predis) which break something we use with its major changes.

I'm back... I first need to upgrade my project to Symfony 3.1

Now I use :

  • Symfony 3.1.10
  • Redis Server 3.0.7 (MacBook Air)
  • PHP 7.1.8
  • "stephpy/timeline-bundle": "2.5.*",
  • "snc/redis-bundle": "2.x-dev",
  • "predis/predis": "1.0.*"

The PHP code above is the same but getTimeline returns always nothing :(

I tried the following code, using Redis without the stephpy/timeline-bundle :

$redis = $this->container->get('snc_redis.default');
$val = $redis->incr('foo:bar');
var_dump($val);

The dumped variable is good incremented.

So is it a bug in this stephpy/timeline-bundle ?

No help ? :(

I'll try to reproduce the bug this week.
Sorry for delay.

OK thanks. My latest attempt was with Symfony 3.2

I found the issue ...
it's about predis and pipelines ...
predis does not follow the phpredis syntax for pipeline, so I had to make this dirty code ... and they changed the pipeline object.

Sorry for delay, I just commited a fix here: https://github.com/stephpy/timeline/releases/tag/v1.1.1

Hi @stephpy , thanks for the fix (in stephpy/timeline) but what about this stephpy/timeline-bundle ? How to get the fix for my composer.json ?

You just have to update stephpy/timeline, timeline-bundle has not to be changed.

I added "stephpy/timeline": "v1.1.1", in my composer.json and it works. Alleluia ;) Thanks !