Autoblog WPML imports produce errors.

Importing posts with autoblog when WPML add-on used creates an error when importing and no posts are imported.

error: "Uncaught InvalidArgumentException: element_id and type do not match for element_id:37514 the database contains post_jobs while this function was called with post_post in \/nas\/content\/live\/splitaditro\/wp-content\/plugins\/sitepress-multilingual-cms\/classes\/core-abstract-classes\/class-wpml-set-language.php:28\nStack trace:\n#0 \/nas\/content\/live\/splitaditro\/wp-content\/plugins\/sitepress-multilingual-cms\/sitepress.class.php(1462): WPML_Set_Language->set(37514, 'post_post', NULL, NULL, NULL, true)\n#1 \/nas\/content\/live\/splitaditro\/wp-content\/plugins\/autoblog\/autoblogincludes\/addons\/wpml_languages.php(56): SitePress->set_element_language_details(37514, 'post_post', NULL, NULL, NULL)\n#2 [internal function]: Autoblog_WPML_languages->notify_wpml(37514, Array, Object(SimplePie_Item))\n#3 \/nas\/content\/live\/splitaditro\/wp-includes\/class-wp-hook.php(286):

  • David

    Hi Vaughan,

    Sorry for such a late reply. This project were put on hold for a while.

    I've tried the patch now and it seams to almost work as expected.

    Imports are being run as expected and posts getting created/updated.

    But, sometimes the posts gets added to the wrong language. Or moved to another language if the post is updated.

    How does AutoBlog know which language in WPML to import the post as?

    Seams like it depends on current users editing the site or something.. Most of the time the posts gets imported to the base language, English, which it should. But a few times they get imported/moved to another of the available languages. Almost as if the import is being done in the language that the Admin is currently editing and if no admin is logged in it defaults to the base language.

    Can you please look into this, thanks!
    Right now a setting or patch to always force import to base/main language would be enough.

  • Vaughan

    Hi David,

    It's quite complicated in a way, it should detect language meta of the RSS.

    but this will depend on the code found.

    sometimes it can be 2 letters. pt or full locale like pt_BR or sometimes pt-br

    and in WPML languages table has multiple codes for the same locale.

    eg. uz_UZ could be either ur (Urdu) or uz (Uzbek) and some don't have any locale at all. makes it difficult to understand how WPML knows the difference in those cases.

    Can you try the attached update.

    I've basically set it so if the feed language isn't detected in the meta, or it has complications determining the feed language from the locale/code given, then it should default to 'en' English language.

    Hope this helps

  • David

    Hi again, a follow up on this.

    The patch supplied did help a great deal but we've still had a few occurrences where previously imported posts got moved to the wrong language when autoblog processes the feed again.

    Not sure if it has something to do with the translation setup for the post type. The post type that we are using Autoblog to import posts to is set up to NOT be translated in WPML.

    The best would be if AutoBlog checked translation setting for the post type and when it's set to not be translated always imports to the base language. Could this be implemented?

  • Vaughan

    Hi David

    It's been a long time. Hope you're good?

    The above should've defaulted to English, but I did change that in our git repository a while ago now.

    Please try the attached version (it includes all the latest fixes too)

    It should default to the base url using get_locale() now if it has trouble detecting feed language or no feed language is set. Before I was just assuming that if a feed language wasn't set in the feed source itself, then that source feed would be english.

    Let me know if this works better for you. :slight_smile:

    I'm attaching the full plugin, not just the fixed files.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.