When I attempted to import the xml file from a WordpressMU instance, I got the following warnings:

* warning: Invalid argument supplied for foreach() in sites/all/modules/wordpress_import/wordpress_import.module on line 880.
* warning: Invalid argument supplied for foreach() in sites/all/modules/wordpress_import/wordpress_import.module on line 168.
* warning: Invalid argument supplied for foreach() in sites/all/modules/wordpress_import/wordpress_import.module on line 343.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in sites/all/modules/wordpress_import/wordpress_import.module on line 353.
* warning: array_merge() [function.array-merge]: Argument #2 is not an array in sites/all/modules/wordpress_import/wordpress_import.module on line 385.
* warning: Invalid argument supplied for foreach() in sites/all/modules/wordpress_import/wordpress_import.module on line 494.
* warning: Invalid argument supplied for foreach() in sites/all/modules/wordpress_import/wordpress_import.module on line 343.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /sites/all/modules/wordpress_import/wordpress_import.module on line 353.

And no content gets imported.

I get this behavior regardless of whether I am importing a single user's blog or all the users' blogs. Any ideas?

CommentFileSizeAuthor
#2 fix_sorting_fix_mu_import.patch663 byteselcuco

Comments

humanchimp’s picture

I have the same problem... I have Drupal 5 and the latest snapshot of the Importer. I have downloaded the contents of a relatively small and simple Wordpress blog, try to import, and this is what I get:

error php 11/17/2008 - 20:48 in_array() [. admin
error php 11/17/2008 - 20:48 Invalid argument supplied for foreach() in ... admin
error php 11/17/2008 - 20:48 Invalid argument supplied for foreach() in ... admin
error php 11/17/2008 - 20:48 array_merge() ... admin
error php 11/17/2008 - 20:48 in_array() ... admin
error php 11/17/2008 - 20:48 Invalid argument supplied for foreach() in ... admin
error php 11/17/2008 - 20:48 Invalid argument supplied for foreach() in ... admin
error php 11/17/2008 - 20:48 Invalid argument supplied for foreach() in ... admin
error php 11/17/2008 - 20:48 Invalid argument supplied for foreach() in ... admin
error php 11/17/2008 - 20:48 Invalid argument supplied for foreach() in ... admin

Has WP updated their XML schema? Or do I have something configured wrong?

elcuco’s picture

StatusFileSize
new663 bytes

The attached path fixes two things:

When exporting from MU $wordpress['categories'] is not set, and then wordpress_import_import_categories() does not return anything (WTF?) which causes wordpress_import_import_blog() to fail (you try to merge an array and NULL). The fix is trivial: at the end of function wordpress_import_import_categories(), after at the end of the function add this code:

  // diego - $wordpress['categories']) is not an array
    return array(
      'categories_map' => null,
      'categories_vocabulary' => null
      );

On wordpress, the comments are displayed from the latest to the newest. After import on Drupal I see the newest comments on the top, so I had to reverse the order of those comments. Inside wordpress_import_post() after the ksort() I added this line:

  // diego - messages should be sorted in reverse order
  $drupal_comment = array_reverse($drupal_comment);

I did a few tests on my local setup and it seems to work, so I attach here a patch against version 6.x-1.0 of the module, people using drupal5 you can always update to drupal6 or patch manually ;-)

yrocq’s picture

Assigned: Unassigned » yrocq
Category: support » bug
Status: Active » Reviewed & tested by the community

I will integrate the code for the categories as soon as possible.

However, note that the change you made for ordering the comments may break the thread hierarchy. A better solution would be to choose the order that you want in the "Default display order" section of the content type form in Drupal.

yrocq’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in branches DRUPAL-5 and DRUPAL-6--1

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.