wp-cli / language-command

Installs, activates, and manages language packs.
MIT License
13 stars 22 forks source link

Inconsistencies with "wp language plugin list..." #51

Closed jkananen closed 6 years ago

jkananen commented 6 years ago

As of the second command below, things start to look odd, but it looks likely that the first list is wrong as not all those plugins have translation updates available. I've checked this with "Update Translations" via the dashboard and git status in command line to see what gets updated, and only gutenberg translations in fact appear as modified.

WP-CLI 2.0.0

Ps. I hope my commands are correct. It would be a good to have a couple more examples in the docs.

Jounis-MacBook-Pro:htdocs jokanane$ wp language plugin list --path=wp_kajovisuals --all --update=available
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
| plugin                | language | english_name | native_name | status    | update    | updated             |
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
| better-search-replace | de_DE    | German       | Deutsch     | installed | available | 2018-03-11 22:39:12 |
| cookie-notice         | de_DE    | German       | Deutsch     | installed | available | 2018-06-28 06:32:06 |
| duplicator            | de_DE    | German       | Deutsch     | installed | available | 2018-07-17 12:04:47 |
| gutenberg             | de_DE    | German       | Deutsch     | installed | available | 2018-08-08 18:38:30 |
| maintenance           | de_DE    | German       | Deutsch     | installed | available | 2016-10-07 12:48:55 |
| query-monitor         | de_DE    | German       | Deutsch     | installed | available | 2018-02-27 16:18:07 |
| redirection           | de_DE    | German       | Deutsch     | installed | available | 2017-01-29 15:55:57 |
| regenerate-thumbnails | de_DE    | German       | Deutsch     | installed | available | 2018-01-31 10:20:35 |
| updraftplus           | de_DE    | German       | Deutsch     | installed | available | 2018-04-30 10:47:25 |
| wordpress-seo         | de_DE    | German       | Deutsch     | installed | available | 2018-07-24 09:32:58 |
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+

Jounis-MacBook-Pro:htdocs jokanane$ wp language plugin update better-search-replace --path=/Applications/MAMP/htdocs/wp_kajovisuals
Using cached file '/Users/jokanane/.wp-cli/cache/translation/plugin-gutenberg-3.4.0-de_DE-1533753510.zip'...
Unpacking the update...
Installing the latest version...
Translation updated successfully.
Success: Updated 1/1 translation.
Updating 'German' translation for Gutenberg 3.4.0...

Jounis-MacBook-Pro:htdocs jokanane$ wp language plugin list --path=wp_kajovisuals --all --update=available
+--------+----------+--------------+-------------+--------+--------+---------+
| plugin | language | english_name | native_name | status | update | updated |
+--------+----------+--------------+-------------+--------+--------+---------+
+--------+----------+--------------+-------------+--------+--------+---------+

Jounis-MacBook-Pro:htdocs jokanane$ cd wp_kajovisuals/

Jounis-MacBook-Pro:wp_kajovisuals jokanane$ git status
On branch dev
Your branch is up-to-date with 'origin/dev'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   wp-content/languages/plugins/gutenberg-de_DE.mo
    modified:   wp-content/languages/plugins/gutenberg-de_DE.po

no changes added to commit (use "git add" and/or "git commit -a")

While it appears that the first list is wrong, I'm still curious as to why gutenberg translations get updated when the call was for better-search-and-replace?

I have noted that the cache is involved in the steps above. How do I clean the wp-cli cache? Is simple rm -rf okay?

I am happy to provide further details of my env per your needs.

swissspidy commented 6 years ago

Huh, very interesting. That does indeed sound really weird.

As for the update command, I'm just looking at the code now and it really doesn't do what it should, namely only install updates for a given plugin.

As for the list command, it doesn't filter updates by plugin slug either:

https://github.com/wp-cli/language-command/blob/9dbefc91038aa04137d9ca0172d734ea1a1201d5/src/Plugin_Language_Command.php#L132-L136

I think I really need to go over these commands again with a fresh perspective...

I have noted that the cache is involved in the steps above. How do I clean the wp-cli cache? Is simple rm -rf okay?

There are no commands for that yet (see https://github.com/wp-cli/wp-cli/pull/4787), but you can rm -rf ~/.wp-cli/cache/translation in the meantime to remove the cached translation updates.

jkananen commented 6 years ago

I removed the cached file - no change in behaviour of the update command:

Jounis-MacBook-Pro:htdocs jokanane$ rm -rf ~/.wp-cli/cache/translation
Jounis-MacBook-Pro:htdocs jokanane$ ll ~/.wp-cli/cache/translation
ls: /Users/jokanane/.wp-cli/cache/translation: No such file or directory
Jounis-MacBook-Pro:htdocs jokanane$ wp language plugin update better-search-replace --path=/Applications/MAMP/htdocs/wp_kajovisuals
Downloading translation from https://downloads.wordpress.org/translation/plugin/gutenberg/3.4.0/de_DE.zip...
Unpacking the update...
Installing the latest version...
Translation updated successfully.
Success: Updated 1/1 translation.
Updating 'German' translation for Gutenberg 3.4.0...

As for the list command, it doesn't filter updates by plugin slug either

I don't know about filtering by slug; the problem I've reported deals merely with incorrectly listed updates that are available. Please note additional output below that lists also those without updates so you'll know that not all are listed as having updates.

Jounis-MacBook-Pro:htdocs jokanane$ wp language plugin list --path=wp_kajovisuals --all --update=available
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
| plugin                | language | english_name | native_name | status    | update    | updated             |
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
| better-search-replace | de_DE    | German       | Deutsch     | installed | available | 2018-03-11 22:39:12 |
| cookie-notice         | de_DE    | German       | Deutsch     | installed | available | 2018-06-28 06:32:06 |
| duplicator            | de_DE    | German       | Deutsch     | installed | available | 2018-07-17 12:04:47 |
| gutenberg             | de_DE    | German       | Deutsch     | installed | available | 2018-08-08 18:38:30 |
| maintenance           | de_DE    | German       | Deutsch     | installed | available | 2016-10-07 12:48:55 |
| query-monitor         | de_DE    | German       | Deutsch     | installed | available | 2018-02-27 16:18:07 |
| redirection           | de_DE    | German       | Deutsch     | installed | available | 2017-01-29 15:55:57 |
| regenerate-thumbnails | de_DE    | German       | Deutsch     | installed | available | 2018-01-31 10:20:35 |
| updraftplus           | de_DE    | German       | Deutsch     | installed | available | 2018-04-30 10:47:25 |
| wordpress-seo         | de_DE    | German       | Deutsch     | installed | available | 2018-07-24 09:32:58 |
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
Jounis-MacBook-Pro:htdocs jokanane$ wp language plugin list --path=wp_kajovisuals --all --status=installed
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
| plugin                | language | english_name | native_name | status    | update    | updated             |
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
| better-search-replace | de_DE    | German       | Deutsch     | installed | available | 2018-03-11 22:39:12 |
| cookie-notice         | de_DE    | German       | Deutsch     | installed | available | 2018-06-28 06:32:06 |
| duplicator            | de_DE    | German       | Deutsch     | installed | available | 2018-07-17 12:04:47 |
| gutenberg             | de_DE    | German       | Deutsch     | installed | available | 2018-08-08 18:38:30 |
| maintenance           | de_DE    | German       | Deutsch     | installed | available | 2016-10-07 12:48:55 |
| query-monitor         | de_DE    | German       | Deutsch     | installed | available | 2018-02-27 16:18:07 |
| redirection           | de_DE    | German       | Deutsch     | installed | available | 2017-01-29 15:55:57 |
| redirection           | fi       | Finnish      | Suomi       | installed | none      | 2017-04-13 10:15:22 |
| regenerate-thumbnails | de_DE    | German       | Deutsch     | installed | available | 2018-01-31 10:20:35 |
| regenerate-thumbnails | fi       | Finnish      | Suomi       | installed | none      | 2016-03-21 14:07:53 |
| updraftplus           | de_DE    | German       | Deutsch     | installed | available | 2018-04-30 10:47:25 |
| wordpress-seo         | de_DE    | German       | Deutsch     | installed | available | 2018-07-24 09:32:58 |
+-----------------------+----------+--------------+-------------+-----------+-----------+---------------------+
swissspidy commented 6 years ago

I don't know about filtering by slug; the problem I've reported deals merely with incorrectly listed updates that are available. Please note additional output below that lists also those without updates so you'll know that not all are listed as having updates.

What I meant with that was:

As soon as there is 1 update for a particular language and plugin, all plugins are indicated to have an update for that language.

The same goes for the update command: you pass slug xy, but it actually installs any available update.

It shouldn't be hard to fix this though. I'll try to find some time at the end of the week.

jkananen commented 6 years ago

OK - I'll leave this env as is (my own, not urgent) and proceed with the other envs (clients) without WP-CLI v2. Looking forward to testing your fixes though - these new features will be helpful :) Thanks.