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.

This topic contains 8 replies, has 3 voices.

Last updated by Carlos Rojas 3 years, 1 month ago.

Assisted by: Carlos Rojas.

Author Posts
May 11, 2022 at 2:24 pm #11200483

nicoS-9

I am trying to:
Access the Media Translation Plugin Page. All OTGS Plugins are on the newest versions. Also WordPress is on the newest version. The error occurs also on a local test environment.

Link to a page where the issue can be seen:
/wp-admin/admin.php?page=wpml-media

I expected to see:
A working page

Instead, I got:
A fatal error message

Bildschirmfoto 2022-05-11 um 16.21.52.png
May 11, 2022 at 5:51 pm #11202043

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hi, thanks for contacting us.

Please enable the WordPress debug log. This will allow us to see if any PHP errors are being produced. More Info: https://codex.wordpress.org/Debugging_in_WordPress Edit wp-config.php and insert the following lines:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Browse to the page with the issue and/or reproduce the issue.

Locate the debug log in: /wp-content/debug.log

Paste the latest lines here. No need to paste the entire log file, just 50 lines or so will do. Please censor any sensitive information.

May 11, 2022 at 5:57 pm #11202059

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hello,
My name is Carlos and I will continue working on this ticket.

Could you share the information requested by my colleague on the previous message?

Regards,
Carlos

May 11, 2022 at 6:41 pm #11202187

nicoS-9

This is the error that appears in the logs:
[11-May-2022 14:16:45 UTC] PHP Notice: Trying to access array offset on value of type bool in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php on line 113
[11-May-2022 14:16:45 UTC] PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php on line 113
[11-May-2022 14:16:45 UTC] PHP Notice: Trying to access array offset on value of type bool in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php on line 113
[11-May-2022 14:16:45 UTC] PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php on line 113
[11-May-2022 14:16:45 UTC] PHP Notice: Trying to access array offset on value of type bool in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php on line 113
[11-May-2022 14:16:45 UTC] PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-image-translate.php on line 113
[11-May-2022 14:18:13 UTC] PHP Fatal error: Uncaught TypeError: Argument 3 passed to WPML_Media_Translations_UI::__construct() must be an instance of WP_Locale, instance of WPML\ST\MO\WPLocaleProxy given, called in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/menus/wpml-media-menus.php on line 89 and defined in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/menus/wpml-media-translations-ui.php:43
Stack trace:
#0 /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/menus/wpml-media-menus.php(89): WPML_Media_Translations_UI->__construct()
#1 /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/class-wpml-media.php(361): WPML_Media_Menus->display()
#2 /srv/www/htdocs/iamhngry/wp-includes/class-wp-hook.php(307): WPML_Media->menu_content()
#3 /srv/www/htdocs/iamhngry/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#4 /srv/www/htdocs/iamhngry/wp-includes/plugin.php(474): WP_Hook->do_action()
#5 /srv/www/htdocs/iamhngry/wp-admin/admin.php(259): d in /srv/www/htdocs/iamhngry/wp-content/plugins/wpml-media-translation/classes/menus/wpml-media-translations-ui.php on line 43

May 12, 2022 at 10:59 am #11207155

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hello,
Thank you for sharing the error message.

I kindly ask you to follow these steps in order to isolate the cause of the issue:
- Create a full backup of the site
- Update any outdated plugins or themes
- Flush any cache memory that might exists
- Deactivate all plugins, except the WPML ones
- Activate a default WordPress theme, like Twenty Twenty
- If the issue disappeared, start by activating the theme and then the plugins, one by one, until the issue appears again and you find the culprit.

Could you tell me the results of the steps described above?

Regards,
Carlos

May 13, 2022 at 11:47 am #11216351

nicoS-9

The issue is in a function that gets all pages from all functions. We save the current language and after processing we set the language back to normal.

$current_lang = apply_filters( 'wpml_current_language', NULL );
$languages = apply_filters( 'wpml_active_languages', NULL, array( 'skip_missing' => 0));

foreach( (array) $languages as $lang ) {
    do_action( 'wpml_switch_language', $lang['code'] );
    /* building query */
    $posts = new \WP_Query( [
        'sort_order' => 'ASC',
        'sort_column' => 'post_title',
        'post_type' => 'page',
        'posts_per_page' => -1,
        'post_status' => 'publish',
    ] );
    // Processing fetched posts.
}
do_action( 'wpml_switch_language', $current_lang );

Do you have an idea why this code produces such an error?

Any hints would be much appreciated

May 13, 2022 at 2:03 pm #11217887

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hello,
Thank you for your message.

In this case, you will need custom coding which falls outside of the scope of our support service. I would recommend you to contact one of our certified partners at this link: https://wpml.org/contractors/ they will be more than happy to help you.

Regards,
Carlos

May 16, 2022 at 7:10 am #11226557

nicoS-9

My issue is resolved now. We found the issue in our code.
At one point during wp initialization we cycled through the available languages to get pages in all languages. Even when switching back to the previously selected language the settings page wouldn't open.

We resolved the issue by altering our query.

May 16, 2022 at 2:04 pm #11230491

Carlos Rojas
WPML Supporter since 03/2017

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hi there,

I'm glad to hear that the issue is solved 🙂

Please don't hesitate to contact us if you need our help in the future with WPML. We will be more than happy to help.
Best regards,
Carlos