• Resolved saschalenz87

    (@saschalenz87)


    Hi I am currently unable to export users due to a traceback:

    
    [03-Jan-2021 09:08:04 UTC] PHP Fatal error:  Uncaught Error: Object of class stdClass could not be converted to string in /wp-content/plugins/import-users-from-csv-with-meta/classes/export.php:242
    Stack trace:
    #0 wp-content/plugins/import-users-from-csv-with-meta/classes/export.php(242): fputcsv(Resource id #725, Array, ',')
    

    I did some investigation and found that it fails due to the the field wpcom_user_data which is part of Jetpack and not a string. It is rather an object.

    I guess fields like this should be serialized before sending it to fputcsv.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Javier Carazo

    (@carazo)

    @saschalenz87,

    This is really strange because all the data there should be filtered before by the function that prepares the data. So this should be serialized.

    I would like to know what’s happening. I want to make sure it works in every WordPress instance and I am not sure what can be happening.

    Thread Starter saschalenz87

    (@saschalenz87)

    @carazo thanks for the reply. I was able to work around the issue by adding the following lines in prepare.

    
    elseif( strtotime( $value ) ){ // dates in datetime format
    	return date( $datetime_format, strtotime( $value ) );
    }
    elseif( ( self::is_valid_timestamp( $value ) && strlen( $value ) > 4 ) || in_array( $key, $timestamp_keys) ){ // dates in timestamp format
    	return date( $datetime_format, $value );
    }
    //work around since $value can be a object(stdClass)#21290 if login is used through jetpack
    elseif( $key == "wpcom_user_data") {
    	return serialize( $value );
    }
    else{
    	return self::clean_bad_characters_formulas( $value );
    }
    

    Not a permanent solution but it just worked for me for now. I don’t see any is_object condition in this method that also might fix it.

    • This reply was modified 5 years, 5 months ago by saschalenz87.
    Plugin Author Javier Carazo

    (@carazo)

    OK I never thought a plugin could save and object (instead of an array).

    I have just prepared the plugin to allow this including a new filter.

    Update and you will get it done.

    Thread Starter saschalenz87

    (@saschalenz87)

    Hi @carazo I can confirm that fixed it for me and I am able to export the users. Thanks.

    Plugin Author Javier Carazo

    (@carazo)

    @saschalenz87,

    Great.

    Any other problem let me know 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Export fails with Jetpack’ is closed to new replies.