Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: ,

This topic contains 12 replies, has 3 voices.

Last updated by Subash Chandra Poudel 1 year, 6 months ago.

Assisted by: Subash Chandra Poudel.

Author Posts
August 9, 2023 at 11:35 pm #14178771

Vincent

Hello,

- I have a development environment, hosting a WP site, where I uploaded WPML manually (everything works fine locally).
- For deployment purposes, I want to sync my plugins by using rsync.
- As stated in this topic, Rsyncing the WPML plugin to servers breaks it: https://wpml.org/forums/topic/when-already-using-composer-and-rsyncing-project-to-server-it-throws-an-error/#post-11109513

Simple steps to (probably) reproduce:
- I create a WP site locally (on VM for example, so rsync command is available)
- I sync the WPML folder to the server :

rsync --archive --compress --del --rsh "ssh" /srv/mysite.test/wp-content/plugins/sitepress-multilingual-cms dev_user@mysite.dev:/var/www/mysite.dev/public/wp-content/plugins

- I activate the plugin on mysite.dev, and this error pops up (plugin can't be activated):

Warning: include(/var/www/mysite.dev/wp-content/public/app/plugins/sitepress-multilingual-cms/vendor/composer/../../classes/language/Detection/CookieLanguage.php): Failed to open stream: No such file or directory in /var/www/mysite.dev/wp-content/vendor/composer/ClassLoader.php on line 576

Warning: include(): Failed opening '/var/www/mysite.dev/wp-content/public/app/plugins/sitepress-multilingual-cms/vendor/composer/../../classes/language/Detection/CookieLanguage.php' for inclusion (include_path='.:/opt/plesk/php/8.0/share/pear') in /var/www/mysite.dev/wp-content/vendor/composer/ClassLoader.php on line 576

Fatal error: Uncaught Error: Class "WPML\Language\Detection\CookieLanguage" not found in /var/www/mysite.dev/wp-content/public/app/plugins/sitepress-multilingual-cms/inc/wpml_load_request_handler.php:18 Stack trace: #0 /var/www/mysite.dev/wp-content/public/app/plugins/sitepress-multilingual-cms/sitepress.php(296): wpml_load_request_handler() #1 /var/www/mysite.dev/wp-content/public/wp/wp-admin/includes/plugin.php(2314): include_once('...') #2 /var/www/mysite.dev/wp-content/public/wp/wp-admin/plugins.php(192): plugin_sandbox_scrape() #3 {main} thrown in /var/www/mysite.dev/wp-content/public/app/plugins/sitepress-multilingual-cms/inc/wpml_load_request_handler.php on line 18

---
As stated by the person in the topic linked above, removing the plugin, and then re-uploading it by hand solves the issue. But this is not an easily acceptable solution for automated deployments 🙂

Do we probably need an extra argument passed to the rsync command? There's something probably missing to preserve the integrity of the files... Probably that some file need to keep execution rights or something... That's out of my skills, but I would appreciate that you take a look because it completely break deployments workflows based on rsync.

Before you ask, after rsyncing, I used scp to download back all the files locally, and git did not find any differrence, any modified or missing file.

Any thought?

Thank you by advanced 🙂

Regards.

August 10, 2023 at 6:49 am #14179433

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for contacting the support forum.
Before assigning your ticket to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

I understand but the problem is not WPML it is rysnc command. It is possible that not all files are not copied. Can you please confirm if those mentioned files in the warning really exist on target server?

1. You can try -v parameters to check the output of command.
2. Also use --delete-before to delete previous files before copy.

I would recommend approaching the system admin for this. I am sorry, but we can't do much here unless you are sure it is WPML's fault.

Thanks

August 10, 2023 at 6:57 am #14179455

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Also, please look at the path
Your target is /var/www/mysite.dev/public/wp-content/plugins

But in warning it says

var/www/mysite.dev/wp-content/public/app/plugins/sitepress-multilingual-cms/

Please check the path you have defined in wp-config.php and correct the target directly.

August 10, 2023 at 10:37 am #14181529

Vincent

Hello,

Thank your for your answer, but,

> I understand but the problem is not WPML it is rysnc command.
WPML is the ONLY plugin affected by this issue. We have about 50 plugins on our site. The only one creating this issue is the WPML plugin.
As mentionned in this issue (https://wpml.org/forums/topic/when-already-using-composer-and-rsyncing-project-to-server-it-throws-an-error/#post-11109513), it looks like there is probably an issue between rsync and the composer installers included in your plugin (I am pretty sure this issue comes from sitepress-multilingual-cms/vendor/otgs/installer).
All others plugins I have also include a composer file.
My main site also include a composer.json as root (it is a bedrock-like stack), like mentionned in the other post.
The guy on this on this topic pointed an issue which is actually real. I just tried to give the additional answer you were asking for: a step-by-step to reproduce.
It's not only an rsync issue, it is about the composer installers being ran after the plugin is deployed through rsync. And it should not happen.
We should actually be able to upload the plugin through FTP, rsync, or the wp-admin, without any differrence. That's not the case.

I am not saying the issue comes more from WPML than rsync. I am just saying that both are conflicting with each others. As I said, there's probably a file that needs specific permissions, and that would be great if, as developers, we could know which ones, so we could still be able to deploy sites without a single plugin crashing the whole process.

> It is possible that not all files are not copied.
The answer is no, as stated in the initial topic :
"Before you ask, after rsyncing, I used scp to download back all the files locally, and git did not find any differrence, any modified or missing file."
However, git does not check permissions.. That's why I guess it can actually be the real culprit.

> 1. You can try -v parameters to check the output of command.
I'll try that and let you know.

> 2. Also use --delete-before to delete previous files before copy.
I tried to deploy on a fresh instance, meaning that actual folders on the destination server were totally empty. I'll still try but that's not the issue.

> I am sorry, but we can't do much here unless you are sure it is WPML's fault.
I gave a step-by-step to reproduce the issue. Not sure what I can do more to confirm there's an issue with the composer installers from WPML.
This issue was inexistent on earlier versions.
However, if you need me to build an example stack, that would be pretty simple. But would you try? It just requires to create a WP instance from a root composer file, by loading johnpbloch/wordpress for example, and then rsyncing the whole site to a server. Once uploaded via rsync, you just won't be able to activate the plugin, and will get, instead, the mentionned errors.

> Also, please look at the path
> Your target is /var/www/mysite.dev/public/wp-content/plugins
My paths are correct. The fact you see an issue there is because I manually changed them while writing my topic to hide sensitive data, since those posts are public. I just made a typo while trying to hide sensitive data.

Regards.

August 11, 2023 at 8:55 am #14187023

Subash Chandra Poudel

Hi there,

Thank you for the details.

> > 1. You can try -v parameters to check the output of command.
I'll try that and let you know.

Please let us know how it goes once you try it.

I have escalated this issue to our team, however in the meantime if you could also create a simple setup and provide us with the details of the site/server and steps to replicate the issue it will help us further troubleshoot the issue.

I have enabled a private reply for you to share the credentials safely.

Regards,
Subash

August 11, 2023 at 9:51 am #14187657

Vincent

Hello,

I figured out that Rsync is not the issue.

Like @juslintek from the linked post, I am using a similar workflow, but completely differrent tools:
- like him, I am cloning a repository which includes the WPML plugin, and a composer.json root file.
- like him, I am running a composer update command with some productions arguments (I think this is where the issue actually comes from).
- like him, I then push the whole directory to the remote servers via rsync.

Rsync is not the issue since I can actually locally unzip the WPML plugin, and then rsync it to the remote.
I think that running the composer install command affects the main vendor directory from my project and breaks the WPML's PSR-4 assignations, which then leads to those "class not found" errors. I am not sure why exactly. This issue does not occur from others plugins. It's only happenning with WPML.

My stack is using Shipit. This is the workaround I had to create (which is similar to juslintek's one). I just unzip your plugin locally and then rsync it to remote. If I don't do that, I get the mentionned errors in the initial topic.

shipit.blTask('composer:install', async () => {
    await shipit.local('composer install --prefer-dist --no-scripts --no-dev --optimize-autoloader', {cwd: shipit.config.workspace});
});

shipit.on('fetched', function () {
    shipit.start('composer:install');
});

shipit.blTask('wpml', async () => {
    await shipit.local('rm -rf /tmp/shipit/sitepress-multilingual-cms && mkdir -p /tmp/shipit/sitepress-multilingual-cms && unzip -q /tmp/shipit/workspace/config/sitepress-multilingual-cms.zip -d /tmp/shipit')
    await shipit.remote('cd httpdocs/current && rm -rf public/app/plugins/sitepress-multilingual-cms && mkdir public/app/plugins/sitepress-multilingual-cms');
    await shipit.copyToRemote('/tmp/shipit/sitepress-multilingual-cms', 'httpdocs/current/public/app/plugins', {
        rsync: ['--delete']
    });
});

shipit.on('published', function () {
    shipit.start('wpml');
})

Note: I also tried the composer install command without the --optimize-autoloader argument: same issue.

This workaround actually fix the issue, but it is bad practice and makes the deployment workflow harder and unusual. Best way to resolve would be, I guess, to figure out why a production composer install command affects the WPML plugin in such a manner.

Best regards.

August 13, 2023 at 9:48 am #14192803

Subash Chandra Poudel

Hi there,

Thank you for your detailed reply with the details of the workaround and confirming the issue is resolved with the workaround.

I will forward the details to our team in case this can help other people or our team.

- In the meantime can you please pass the -c parameter to check for checksums and let me know how it goes?

- Also, can you please let me know if this happens only on the first/initial rsync? Or does it also happens after the files are synced initially, WPML is fixed with manual install/update then further rsync of the files?

Regards,
Subash

August 13, 2023 at 5:59 pm #14193593

Vincent

Hello,

> In the meantime can you please pass the -c parameter to check for checksums and let me know how it goes?
I'll try that and let you know. However, I assume you are still expecting a missing or corrupted file while uploading to the remotes. As said previously, I already checked that the files were correctly uploaded by downloading them back, and then by making a git compare (but I'll try to also make a test from a project without any gitignore file... just to be sure, and I'll let you know). I think that the problem appears in the root_project/vendor directory (after executing a composer install (with given arguments above), not in the root_project/wp-content/plugins/sitepress-multilingual-cms/vendor directory.

> Also, can you please let me know if this happens only on the first/initial rsync? Or does it also happens after the files are synced initially, WPML is fixed with manual install/update then further rsync of the files?
This happens on every sync, even if the plugin has not been updated, even if there is absolutely no change to the plugin, even if I previously temporarily fixed the error by manually uploading the plugin via the WP plugins page, which actually probably confirm that the issue appears somewhere else than in your plugin folder. Again, I think that the problem occurs in a project that contains a root composer.json file. Composer is somehow breaking the PSR-4 assignations from your plugin but I don't know why. However, this seems to be an issue largely reported (hidden link). But I simply can't figure out the issue since your plugin does not include the composer.json file.

I'll check in the next few days about the mentioned tests and will let you know.

Regards.

August 15, 2023 at 11:17 am #14202621

Subash Chandra Poudel

Thank you for the updates,

Our team is still looking into the issue further.

In the meantime, can you please check and let us know if you or any of the plugins on the site use Monolog or PSR/login for your setup? It will help us verify if the issues could be related to other known issues and help us further troubleshoot the issue.

Also, please let us know how it goes when you pass the -c parameter once you test it.

September 1, 2023 at 9:09 am #14325363

Subash Chandra Poudel

Hi there,

I would appreciate if you could let me know the answer to my question in the previous reply linked next, this will help our second tier team troubleshoot the issue further.

https://wpml.org/forums/topic/wpml-cant-be-deployed-via-rsync/#post-14202621

Also, did you got a change to run the "-c parameter" and see how it goes?

Regards,
Subash

September 1, 2023 at 4:19 pm #14328065

Vincent

Hello there,

I was answering your requests, and then decided to perform a few more tests.... Until I finally realized that the path requesting the CookieLanguage.php file is.... Wrong !! ^^

As you can see in my initial message, I posted this:

Warning: include(/var/www/mysite.dev/wp-content/public/app/plugins/sitepress-multilingual-cms/vendor/composer/../../classes/language/Detection/CookieLanguage.php): Failed to open stream: No such file or directory in /var/www/mysite.dev/wp-content/vendor/composer/ClassLoader.php on line 576

I took a look onto my repository, and the file is not located in the "language" directory, but in the "Language" directory (notice the first capitalized letter !).

Did you somehow change that folder name some time ago or something?

If I unzip your folder, the language folder isn't capitalized, and exists as "language".
If i check my online repository, the Language folder is capitalized and exists as "Language" (updated 3 weeks ago).

Well... This appears to be a Git issue. I don't understand why and how it is possible, but Git did not take care about a "language" folder being probably renamed to "Language", and that made hell a mess.

To fix and confirm the issue, I deleted WPML from my repository, and then unzipped the plugin again, committed and pushed again. I can now see the correct structure on my Gitlab.

I'll still need to test and finally confirm the issue by removing my workaround, and attempt to deploy normally, and I'll let you know (but I think it will fix it).

By the way, since Git seems to be involved in that big headache, this is the version, in case that can help: Git for Windows 2.41.0

I am normally using PHP Storm to commit, but I noticed a strange behavior on Gitkraken. I wasn't able to unstash the files located in the Language directory... They were buggy. I never saw that behavior before so I check the repository and noticed this issue. Git was stuck on updating files within a language directory while he was expecting to do that into the language directory.

I'll let you know about the final result.

Best regards.

September 1, 2023 at 5:44 pm #14328355

Vincent

Just decided to search the web about "this git issue"... It is not one, but it looks like it is just the default Git behavior.
It seems that by default, Git doesn't care about capitalization changes.... https://stackoverflow.com/questions/6899582/i-change-the-capitalization-of-a-directory-and-git-doesnt-seem-to-pick-up-on-it

What a nightmare... Looks like

git config core.ignorecase false

is a must use...

I wasn't expecting this...

Sorry I reported such a "WPML issue" while the solution actually stands in a single Git config line...

Regards.

September 4, 2023 at 3:46 pm #14338385

Subash Chandra Poudel

Thank you for confirming that the original issue is resolved and sharing the fix with us.

This will help other people with similar cases in the future.

Feel free to mark this ticket as resolved if you no longer need help with this issue and also feel free to contact us again in future for any help or queries regarding WPML.

September 7, 2023 at 9:03 am #14357461

Vincent

Thank you for your patience and the interest you put into that issue. I hope this ticket will help anyone struggling with that kind of git configuration strangely leading to missing files after updating.

Best regards.