Yeah, that's exactly why I was asking for support: is seems that WPML is incompatible with wp-cli regenerate and that's a huge deal breaker for any website owner that has more than, say, 200 images, which is pretty common these days, because using Regenerate Thumbnail for such a demanding task is not a feasible option.
I have another feedback and this is what they mentioned.
WPML is not supposed to do anything with the attachment files. WPML handles only database entries. Extending the functionality to handle the files is definitely out of scope here and could create performance issues and it won't be desirable for most of the users.
It does not have to handle files in any way and it's not what the issue is about. You're just bouncing a legit bug back.
WPML duplicates attachment IDs and the related attachment meta_value. When a original language attachment is regenerated via wp-cli, it's WPML that should hand the synchronization of the updated meta_value for the corresponding translated attachment ID.
There's anything to do with files, it's just a database entry that WPML should update in the postmeta table.
This is intended behaviour and it's in fact what happens when using Regenerate Thumbnail, because of it relying on action hooks that get triggered only in wp-admin environment and not on wp-cli environment.
This is what should be fixed, not files. I have never ever mentioned files.
I've received feedback from our 2nd Tier Support regarding your query. From their perspective, this appears to be more of a feature request.
I do have a tentative workaround that you may suggest to the user:
Navigate to the file: `wp-content/plugins/sitepress-multilingual-cms/classes/request-handling/class-wpml-language-resolution.php`
Within the method: `\WPML_Language_Resolution::filter_for_legal_langs`, insert the following condition:
if (defined('WP_CLI') && WP_CLI) {
global $argv;
$command_line = implode(' ', $argv); // Convert arguments to a single string
// Check if 'wp media regenerate' is in the command line
if (strpos($command_line, 'media regenerate') !== false) {
$lang = "all";
}
}
Insert the code snippet above just before the `return $lang;` line. This modification should ensure that when running `wp media regenerate`, elements from ALL languages are processed.
Please note:
- This solution might have some bugs.
- No warranties are provided with this workaround.
Hi Kor, I do not understand how this can be seen as a feature request, as wp-cli is pretty widespread in serious projects and I think that the Wpml team should acknowledge the issue, however i must thank you for reporting and insisting with the 2nd tier team.
I will run regenerate again on the test environment as soon as possible to let you know if it's working fine.