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

Buggy Message console tool #17532

Closed
OndrejVasicek opened this issue Aug 27, 2019 · 4 comments
Closed

Buggy Message console tool #17532

OndrejVasicek opened this issue Aug 27, 2019 · 4 comments
Labels
help wanted status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@OndrejVasicek
Copy link
Contributor

The Message tool which extracts translations from source code and creates new translations for given languages works like a charm in those situations

  1. When the list of languages since the last run is the same as current list of languages and there are some new translations - new texts in source code is found and properly inserted into source messages and new translations for languages are made.
  2. When there are new languages and no new translations since the last run – no new texts in the code are found but translations for new languages are created.

But I came across a situation where there are new translations and new languages since the last run. In this case, the tool doesn’t work properly. When you run it, it end up with SQL error – the tools tries to break pk_message_id_language primary key. The result is interesting – the “old” languages got new translations and are complete, but the new languages got only the new translations and the old ones aren’t created.

If you run it second time, no sql error but no new messages are created. New languages has translations only for the new messages created in the previous buggy run.

Unfortunately, the source code of the tool is too complicated to me to fix it. My “workaround” for me was (after the broken run) to delete all translations from the new languages. Then I was in the second working example – new languages but no new translations. Then when you run the tool, it works.

I also trid to delete the primary key, but the tool just created duplications.
So clearly, the tool is buggy, but I’m not able to fix it

Additional info

Q A
Yii version 2.0.16
PHP version 7.1.4
Operating system Win10
@yii-bot
Copy link

yii-bot commented Aug 27, 2019

Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:

  • When does the issue occur?
  • What do you see?
  • What was the expected result?
  • Can you supply us with a stacktrace? (optional)
  • Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)

Thanks!

This is an automated comment, triggered by adding the label status:need more info.

@OndrejVasicek
Copy link
Contributor Author

What specific info do you need? I tried to describe it as detailed as possible.

The first three questions are answered in my post.
I don’t know what stacktrace is.
There is no exact code, only the run command yii message path/to/config. The problem is in the tool when it gets specific kind of data I described above.

@samdark
Copy link
Member

samdark commented Aug 27, 2019

  1. Your messages config for the component.
  2. Your messages config for the console tool.
  3. Some files you are analyzing.
  4. Sequence of running commands.

@OndrejVasicek
Copy link
Contributor Author

Your messages config for the component.

    'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\DbMessageSource',
                    'enableCaching' => !YII_DEBUG,
                    'cachingDuration' => $params['cache.medium'],   // 10 minutes
                ],
                'api*' => [
                    'class' => 'yii\i18n\DbMessageSource',
                    'enableCaching' => !YII_DEBUG,
                    'cachingDuration' => $params['cache.medium'],
                ],
                '*' => [
                    'class' => 'yii\i18n\DbMessageSource',
                    'enableCaching' => !YII_DEBUG,
                    'cachingDuration' => $params['cache.medium'],
                ],
            ],
        ],

Your messages config for the console tool.
These are the uncommented lines

'sourcePath' => dirname(DIR) . DIRECTORY_SEPARATOR . '..',
'languages' => ['cs', 'de', 'sk', 'hu', 'pl', 'sl', ],
'translator' => ['Yii::t', 'Helper::t', 'Helper::tp', 'Helper::tExist',],
'sort' => false,
'removeUnused' => false,
'markUnused' => true,
'only' => ['*.php'],
'except' => [
'.svn',
'.git',
'.gitignore',
'.gitkeep',
'.hgignore',
'.hgkeep',
'/messages',
'/environments',
'/tests',
'/vagrant',
'/vendor',
'/frontend/web/admi',
],
'format' => 'db',
'db' => 'db',

Some files you are analyzing.
Regular PHP files, there is no probleme here - the extraction works like a charm in the first two scenarios.

Sequence of running commands.
I only run yii message common/config/message.php.
Sometimes I tried to flush the cache before, but it didn't have any effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

4 participants