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.

Elementor users - please update WPML to the latest version to maintain compatibility. More details here - https://wpml.org/changelog/2024/12/wpml-4-6-15-critical-update-for-elementor-sites/
Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Bruno Kos 3 months, 2 weeks ago.

Assisted by: Bruno Kos.

Author Posts
August 29, 2024 at 2:01 pm #16120494

desireeM

Background of the issue:
WPML and WCML use WP_Filesystem_Direct directly instead of using the $wp_filesystem global e.g. in
sitepress-multilingual-cms/classes/utilities/class-wpml-flags-factory.php
sitepress-multilingual-cms/classes/wpml-wp/class-wpml-wp-api.php
woocommerce-multilingual/addons/wpml-dependencies/lib/classes/wpml-wp/class-wpml-wp-api.php

There are more files and this issue also exists in wpml-string-translation plugin

This is a problem bc in WP core the filesystem is filterable: $abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );

For security reasons we have extended the WP_Filesystem_Direct class and filtered it on WP filter

However, WPML won't use it but instead incorrectly instantiates WP_Filesystem_Direct separately.
This is wrong and not how WP Filesystem classes should be used.
Use the $wp_filesystem global instead, just like all other plugins too.

Symptoms:
Custom filesystem class is not used

Questions:
Why does WPML use WP_Filesystem_Direct directly instead of the $wp_filesystem global?

When do you fix this?

September 2, 2024 at 5:34 am #16129963

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Hi,

I am checking this with our developers and will get back to you.

September 2, 2024 at 6:52 am #16130087

desireeM

What's extra annoying is that you also require_once that class - so if we reuse the identical class name to work around the other stuff, but filter in our path, it will result in a fatal error, since you load the original class in sitepress-multilingual-cms\classes\utilities\class-wpml-flags-factory.php (and sitepress-multilingual-cms\classes\wpml-wp\class-wpml-wp-api.php)

>require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';

September 2, 2024 at 8:21 am #16130500

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

According to our older commits this may have been done intentionally because of restrictions from the WP_Filesystem object not providing the proper file path.

That being said can you give us some context where this causes you issues (e.g. plugin or a theme update or similar)?

September 2, 2024 at 10:02 am #16130829

desireeM

Everywhere, because anything you try with WP_Filesystem_Direct fails, bc it's not supported on one of our systems. That's why we use the WP core filters to implement our own filesystem that implements the file system we use.
It's a similar system like WordPress itself provides in WP VIP hidden link

September 3, 2024 at 7:16 am #16134119

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

This issue has been escalated to WPML developers.

I will keep this thread updated as soon as I get any new information from them!