Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 4.4.6

Resolved in: WPML 4.4.8

Overview of the issue

If you go to the Customizer or Widgets page in your site’s admin, a blank page or fatal error is shown:

PHP Fatal error: Uncaught InvalidArgumentException: item should be a Collection or an array or an object in .../wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Obj.php:97

Workaround

  • Make a full backup of your site before proceeding.
  • Open the file /wp-content/plugins/sitepress-multilingual-cms/classes/widgets/class-wpml-widgets-support-backend.php.
  • Change:
    			'selected_language' => Obj::propOr( 'all', 'wpml_language', $instance ),
  • To:
    			'selected_language' => Obj::propOr( 'all', 'wpml_language', is_array( $instance ) ? $instance : [] ),
  • Edit your Customizer options and/or widgets.
  • When done editing, remove the code added in step 2.
  • Open the file: wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php
  • Change:
    		$post_types = get_post_types( $args, 'objects' );
    
    		foreach ( $post_types as $name => $attrs ) {
    			$slug = trim( Obj::pathOr( '', [ 'rewrite', 'slug' ], $attrs ), '/' );
    			if ( $slug && isset( $vars[ $slug ] ) ) {
    				$post_type = $name;
    				$post_slug = $vars[ $slug ];
    				break;
    			}
    		}
  • To:
    		$post_types = get_post_types( $args, 'objects' );
    
    		foreach ( $post_types as $name => $attrs ) {
    		    if ( $attrs->rewrite == false ) {
    		        break;
    		    }
    			$slug = trim( Obj::pathOr( '', [ 'rewrite', 'slug' ], $attrs ), '/' );
    			if ( $slug && isset( $vars[ $slug ] ) ) {
    				$post_type = $name;
    				$post_slug = $vars[ $slug ];
    				break;
    			}
    		}
    

26 Responses to “PHP Fatal error on Customizer or Widgets page: "Uncaught InvalidArgumentException: item should be a Collection or an array or an object in /sitepress-multilingual-cms/vendor/wpml/fp/core/Obj.php:97"”

  1. I’m getting this exact error after upgrading to 4.4.7 today. In 4.4.6, everything worked fine.

    Adding if (is_string($item)) { return null; } did *not* fix the problem.

    gettype($item) shows it’s a boolean!

    After adding if (is_bool($item)) { return null; }, my site works again, but I don’t know if this doesn’t break something else…

  2. Hello,

    I upgraded all my WPML components this morning. I have now the following error : Fatal error: Uncaught Exception: item should be a Collection or an array or an object

  3. Just wanted to chime in that after updating to 4.4.7 I am also receiving this critical error which takes down the front end of the site.

    Rolling back to 4.4.6 solved it.

    Will wait for confirmation that this is resolved before updating further.

  4. downgraded to 4.4.6. Sent debug info in the support chat. I couldn’t update only ONE page – my homepage – updating all other pages worked fine.

  5. Hi, we have this in combination with RankMath & WPML Plugin enabled – on edit/saving post/pages:

    PHP Fatal error: Uncaught InvalidArgumentException: item should be a Collection or an array or an object in /web/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/fp/core/Obj.php:97

    • I imagine that this can help you solve the issue:

      Since WordPress 5.2 there is a built-in feature that detects when a plugin or theme causes a fatal error on your site, and notifies you with this automated email.

      In this case, WordPress caught an error with one of your plugins, Dynamic Content for Elementor.

      First, visit your website (https://xxx.ch/) and check for any visible issues. Next, visit the page where the error was caught (https://xxx.ch/wp-admin/admin-ajax.php) and check for any visible issues.

      Please contact your host for assistance with investigating this issue further.

      If your site appears broken and you can’t access your dashboard normally, WordPress now has a special “recovery mode”. This lets you safely login to your dashboard and investigate further.

      https://xxx.ch/wp-login.php?action=enter_recovery_mode&rm_token=5fwkIrBjH7pEY3in2AruZu&rm_key=lPHHFFEL6tb2qst3H8ea7D

      To keep your site safe, this link will expire in 1 day. Don’t worry about that, though: a new link will be emailed to you if the error occurs again after it expires.

      When seeking help with this issue, you may be asked for some of the following information:
      WordPress version 5.5.3
      Current theme: Hello Elementor Child (version 1.0.1) Current plugin: Dynamic Content for Elementor (version 1.9.6.7.2) PHP version 7.4.13

      Error Details
      =============
      An error of type E_ERROR was caused in line 4 of the file /home/yyy/www/xxx.ch/wp-content/plugins/dynamic-content-for-elementor/includes/compatibility/wpml/widgets/class-WPML-AnimateText.php. Error message: Uncaught Error: Class ‘WPML_Elementor_Module_With_Items’ not found in /home/yyy/www/xxx.ch/wp-content/plugins/dynamic-content-for-elementor/includes/compatibility/wpml/widgets/class-WPML-AnimateText.php:4
      Stack trace:
      #0 /home/yyy/www/xxx.ch/wp-content/plugins/dynamic-content-for-elementor/includes/compatibility/wpml/class-DCE-WPML.php(63): require_once()
      #1 /home/yyy/www/xxx.ch/wp-content/plugins/dynamic-content-for-elementor/includes/compatibility/wpml/class-DCE-WPML.php(50): DynamicContentForElementor\Compatibility\DCE_WPML->load_wpml_compatibility_classes()
      #2 /home/yyy/www/xxx.ch/wp-content/plugins/dynamic-content-for-elementor/core/DCE_Plugin.php(138): DynamicContentForElementor\Compatibility\DCE_WPML->__construct()
      #3 /home/yyy/www/xxx.ch/wp-content/plugins/dynamic-content-for-elementor/core/DCE_Plugin.php(39): DynamicContentForElementor\DCE_Plugin->init_components()
      #4 /home/yyy/www/xxx.ch/wp-content/plugins/dynamic-content-for-elemento

      • Hello there,
        This issue should have been solved with out latest version WPML 4.4.8. Could you please make a full backup of your site and update all your WPML package?

        Regards

    • Hello there,
      This issue should have been solved with out latest version WPML 4.4.8. Could you please make a full backup of your site and update all your WPML package?
      Sorry for the inconveniences.

      Regards