Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 3.6.0

Resolved in: 3.6.1

Overview of the issue

When using certain themes, you can get the following fatal error that breaks the display of the page:

Fatal error: Uncaught exception ‘InvalidArgumentException’ with message ‘Argument ID must be numeric and greater than 0’

Workaround

The issue is caused by the themes in question because they are passing arguments with incorrect type (arrays instead of objects) to WordPress filters.

This issue will be resolved in the next release by enforcing the usage of correct type by the variables.

In the meantime, you can patch the code by manually adding the following line to the sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-render.php file, at line 127 (at the top of the function):

$args = (object) $args;

After the patch is applied, the code should look like this:

//...
public function wp_nav_menu_objects_filter( $items, $args ) {
$args = (object) $args;
$menu_id = isset( $args->menu->term_id ) ? $args->menu->term_id : null;
//...

2 Responses to “Fatal error: Uncaught exception 'InvalidArgumentException'”

  1. For me not help this patch.

    public function wp_nav_menu_objects_filter( $items, $args ) {
    $args = (object) $args;
    $menu_id = isset( $args->menu->term_id ) ? $args->menu->term_id : null;
    $slot = $this->settings->get_menu_settings_from_id( $menu_id );

    if( $slot->is_enabled() && ! $this->is_hidden( $slot ) ) {
    $lang_items = $this->get_menu_items( $slot );

    if ( $lang_items ) {
    if ( 'before' === $slot->get( 'position_in_menu' ) ) {
    $items = array_merge( $lang_items, $items );
    } else {
    $items = array_merge( $items, $lang_items );
    }
    }
    }

    return $items;
    }