kaliop-uk / ezmigrationbundle

This bundle makes it easy to handle eZPlatform / eZPublish5 content upgrades/migrations
GNU General Public License v2.0
53 stars 81 forks source link

Generating migration in specified language is not working #166

Closed damianz5 closed 6 years ago

damianz5 commented 6 years ago

[Ezplatform demo] - after adding a new language to blog_post, I've tried to generate a migration using command:

bin/console kaliop:migration:generate --format=yml --type=content --match-type=content_type --match-value=blog_post --mode=create --lang=fre-FR

the result file was generated with proper lang: fre-FR but attributes was empty attributes: { }

workaround is to replace this line https://github.com/kaliop-uk/ezmigrationbundle/blob/master/Core/Matcher/ContentMatcher.php#L101

with:

$results = $this->repository->getSearchService()->findContent($query, ['languages' => ['fre-FR']]);

the language code parameter (--lang=) should be passed to findContent method

gggeek commented 6 years ago

Seems weird... the correct language used to serialize the attributes is used in https://github.com/kaliop-uk/ezmigrationbundle/blob/master/Core/Executor/ContentManager.php#L559

I will investigate a bit more

gggeek commented 6 years ago

Tested with ezplatform 210:

got correct results:

-
    type: content
    mode: create
    content_type: testct
    parent_location: 2
    priority: 0
    is_hidden: false
    sort_field: name
    sort_order: ASC
    remote_id: 73cdfd20849fad9786bdfeaa988a50ce
    location_remote_id: 7773bd50d64fe204a6aa463ca1d93df1
    lang: fre-FR
    section: 1
    owner: 14
    modification_date: 1532131229
    publication_date: 1532131132
    always_available: false
    attributes:
        title: 'Test (french)'
        tags: {  }
gggeek commented 6 years ago

Same when I created a content directly in french:

-
    type: content
    mode: create
    content_type: testct
    parent_location: 2
    priority: 0
    is_hidden: false
    sort_field: name
    sort_order: ASC
    remote_id: 175fc559bcf0ba5abea16b126d554acf
    location_remote_id: 41129a0ea2ad97183749d880f5b6c100
    lang: fre-FR
    section: 1
    owner: 14
    modification_date: 1532131898
    publication_date: 1532131898
    always_available: false
    attributes:
        title: 'Test2 (french only)'
        tags: {  }

In other words: can not reproduce :-(

gggeek commented 6 years ago

OK, so maybe I misunderstood what you were asking for. Maybe you meant that, in case the language parameter is passed as command line option, the 'generate' command should not generate creation yml for contents that are not translated in that language ?

If so, I think that this topic could be expanded a bit, taking into consideration:

  1. the possibility of adding multiple fiters as cli options, instead of just one plus language
  2. once the other PR is merged which allows creation/update of a content in many languages, to change the generated yml to include all languages
gggeek commented 6 years ago

Ping. Any feedback ?

gggeek commented 6 years ago

2nd ping. Will close in 1 month if still open...

damianz5 commented 6 years ago

could you describe what was the exact steps for 'added new language: french (fre-FR)'? it was added by AdminUI or/and ezplatform.yml?

damianz5 commented 6 years ago

It works for me for ezplatform repo / master branch as you described, but not for ezplatform-demo repo / master... configuration looks the same in both cases https://github.com/ezsystems/ezplatform-demo/blob/master/app/config/ezplatform.yml#L74 Do you see what may be the issue here?

damianz5 commented 6 years ago

I've just noticed that there is ^4.0 on ezplatform-demo for this bundle - changing it to ^5.0 fix the issue. Thank you for retest, issue can be closed.