Skip to content
 

Serendipity to WordPress – Post import

The first thing you need to do in migrating from Serendipity to WordPress, is to move the post content. Luckily for all of us, at some point in time an importer was written (and shared). It has floated around the internet for a while and been updated a number of times. The version I used was verison 1.3, last updated by a German fellow. While his updates were good, I needed a little more out of it. Two pieces that were lacking were the handling of drafts vs published posts (John and I have a number of drafts, as has been previously mentioned) and the most important, matching up post id numbers. Without that one piece, you can’t move between the two platforms and maintain any links.

The first piece is easy, the second isn’t as much. WordPress doesn’t allow you to select your own post IDs during the post creation routine. Fortunately for you and me, there is a workaround, it involves a little bit of SQL, but anyone with the ability to READ and operate PHPMyAdmin (or command line MySQL), should be able to do this. So I’m proud to announce Serendipity (S9Y) importer for WordPress 1.4. You can also hit up my SVN directly.

Please READ the readme.txt file. It is short and contains all the instructions (and SQL) you need. If you follow the instructions properly, you should be able to import a fair sized blog (~1000 entries/comments) in less than 10 minutes.

(To anyone that might update this again, I’m happy to give you commit access to SVN to check in the new version. Or just send it back to me and I’ll post it.)

Related posts:

  1. A possible migration to WordPress
  2. Houston, We have WordPress
  3. Serendipity Upgrade

27 Comments

  1. [...] This post was mentioned on Twitter by Jon, John. John said: RT @ShakataGaNai: [Blog] Serendipity to WordPress – Post import http://bit.ly/d5HXfo [...]

  2. [...] the second most important thing to for a S9Y to WordPress migration, after you import the posts, is to make sure as many of the old links work as possible.  It doesn’t actually require all [...]

  3. [...] Update 2: Jon reports that he’s improved on Carsten’s 1.3 version, and has released Version 1.4! [...]

  4. [...] Zwischenzeitlich gibt es eine neue Version, die 1.4 von Jon… (ich habe sie selbst nicht [...]

  5. [...] und neu veröffentlicht wird. “Meine” Version war die 1.3 und nach einiger Zeit gibt es nun die Version 1.4 – und natürlich nicht von [...]

  6. Mark says:

    I am in the same boat as you were, and I love hearing that you were able to successfully move from Serendipity to WordPress – gives me hope! I started my site with Serendipity a couple of years ago, but over time I have grown tired of dealing with annoying work-arounds and other things (along with the non-working autosave you mentioned), so with WordPress 3.0 now released (I’ve been reading about it for quite awhile, including it’s absorption of WordPress MU), I figured I’d test it out and see if I could make the switch.

    I’m really glad to have found your work, since I’m not TOO technical of a guy. I have some questions, though:

    (I know that this was not created for WordPress 3.0, but I am hoping to discover that my problems are my error, so I don’t have to install a lower version and then upgrade.)

    1. I attempted to follow “Truncate (remove) all records from: `wp_posts`, `wp_postmeta`, `wp_term_relationship`, `wp_term_taxonomy`” but I received an error each time that told me removing all columns was not allowed and that I needed to simply drop the entire section. My mistake in misunderstanding the directions, or a WordPress version difference?

    2. After a few attempts, I figured I’d try and sidestep it, JUST to see if it might work. I was thrilled to see Categories import, and then Users, however, upon reaching the import for posts, I received this error… “Fatal error: Call to undefined function: array_walk_recursive() in /ROOT/wpTest/wp-admin/import/serendipity.php on line 419″

    I really hope to find an answer to these problems, so that I can move on to testing layout and design, and I appreciate it.. in advance.

    • Mark says:

      Ah, I’m a bit of a boob. I noticed that it HAD been tested for WordPress 3, though I am currently running Serendipity 1.5.3, not the tested 1.5.2.

      Also, I have since discovered (another D’oh! on my part) the Empty option in the database, yet the error still occurs on import.

      • Jon says:

        #1 – Sorry, I shall have to find the proper commands and clarify the instructions. By “Truncate” I meant “Delete all records”. All except for default category in `wp_terms`. You _shouldn’t_ have any records in any of these tables if you just installed WordPress – but I’ve seen it create a record in `wp_posts` for the auto-draft plugin on the dashboard.

        So in case that ins’t clear enough, delete just the data – not the actually structure of the tables. If you did modify the table layout, your fastest option will just be to nuke the install and redo it.

        #2 – array_walk_recursive() is a function from PHP 5. My guess would be your running PHP 4? Check what version.

        #3 – I’m fairly confident you’ll be fine on anything 1.5.X, probably back farther. The database layout in Serendipity hasn’t change much in the last few versions (that I’ve seen).

        -Jon

        • Mark says:

          Thanks for the response :)

          1. No, you did just fine – my error was due to a lack of knowledge. Pretty much, I just didn’t know what I was doing ;) . That’s how we learn, though, and I’ve figured out how to empty the tables (sans the one you suggest I don’t).

          2. I’ve had issues getting WordPress to install on PHP 5, before, so I had it on 4.1 before. I just did a fresh WordPress install using PHP 5, though my Serendipity DB is on PHP 4.1. I still receive the error, so in the serendipity.php file I commented out rows 418-420 to erase the if statement that function was attached to – and it all worked like a charm!

          Thank you very much! I never quite imagined I’d be leaving Serendipity (as much as I’d enjoyed working with, and recommended, WordPress for others), but this is going to be a good thing :)

          • Jon says:

            #1 – Awesome!

            #2 – Ok, that would explain why the error was there. The lines around that array_walk_recursive() are for S9y Tags, so if you didn’t have any tags (S9y supported tags?!) – you wont have lost anything.

            Glad to hear it all worked out. I look forward to see how your migration work out!

  7. Probleme 2.0…

    Momentan kämpfe ich an mehreren Fronten mit den Tücken des Internets. Grazr hat wohl seinen Dienst eingestellt. Seit Jahr und Tag nutze ich diesen Dienst, um relativ komfortabel auf meiner privaten Seite den Feed dieser Seiten zu präsentieren. Jetzt…

  8. PerfectCr says:

    Maybe I am a total noob, but where do I put my old S9Y sql backup file? I have my new db setup for WordPress. I backed my old S9Y db about a year ago and now want to import it. So I guess I don’t know where to begin. :( Thanks for any help or guidance you can provide!

    • Jon says:

      You’ll need to restore the backup file into MySQL. Once it is life in MySQL, you can use the wordpress import tool to point at that database you just restored.

      • PerfectCr says:

        Thanks for your help on Twitter! I’ve loaded the S9Y DB into it’s own database via Bigdump. It’s on the same server but in a different DB so as not to mix WP and S9Y. (should I have imported the S9Y SQL backup into the same DB as WordPress?) All fields are filled in properly and unfortunately nothing happens. Just says 0 items imported on every page. :( I don’t know what else to do. I feel like I am so close, and yet so far. Pic — > http://twitpic.com/2d9w1j

        • Jon says:

          Not the same DB. Different DB’s for S9y and WP is correct. I’m curious is to how you are getting zero.

          Go into PHPmyAdmin or similar, get a SQL window open & run the following:

          use $DATABASE$;
          SELECT categoryid, category_name FROM $PREFIX$_category

          Replace $DATABASE$ and $PREFIX$ with the values you used from the import step (“Serendipity Database Name” and “Serendipity Table prefix (if any):” respectively).

          If you get no results, then you’ve got the wrong information. If you do get data out, then… we’ve got other problems.

          • PerfectCr says:

            That worked…..!!! (was missing the Prefix Table, sorry) to a point…Imported categories, then on the second page (importing users) I was hit with the following error:

            Catchable fatal error: Object of class WP_Error could not be converted to string in /home/perfectcr/mysite.com/wp-includes/formatting.php on line 2772

            Sorry to be a pest, I am sure you are ready to kill me. I’ll give you a huge shout out on my new site once this is all sorted I promise. Thank you again!

  9. PerfectCr says:

    FYI I replaced “mysite.com” above instead of putting my actual domain there. Wanted to say that in case there was any confusion. Thx!

  10. PerfectCr says:

    Figured it out!!! Apparently, you cannot have the same user name on WP as you did in S9Y nor the same email. I setup a new user in WP, logged in, and deleted the other user and the import completed! Yahoo!!

    • PerfectCr says:

      Sorry to spam your blog :( “One more thing”…

      I was able to run most of the SQL commands without issue, expect the below two SQL queries from your readme returned this error: #1062 – Duplicate entry ’0′ for key ‘PRIMARY’

      UPDATE `wp_comments` as a SET a.`comment_post_ID`= (SELECT b.`menu_order` FROM `wp_posts` as b WHERE a.`comment_post_ID`= b.`ID`);

      UPDATE `wp_posts` SET `ID`=`menu_order`, `guid`=CONCAT(“http://MYURL.COM/?p=”,`menu_order`), `menu_order`=null;

      Once I get this all figured out I am going to delete the WP install and start over and do it right! :)

      • Steve says:

        @PerfectCr did you ever figure out why you were getting an error message on this:

        UPDATE `wp_posts` SET `ID`=`menu_order`, `guid`=CONCAT(“http://MYURL.COM/?p=”,`menu_order`), `menu_order`=null;

        I am having the same problem and am wondering if this is related to an issue I’m having with comments. All of the comments have them have been transferred to the WP database, each post shows the proper number of comments, but when you click on the post no comments appear.

        ~Steve

        • Jon says:

          That specific line updates the post ID’s to the “old” ID numbers. If that failed (but the comment line before didn’t), then your comments have been moved over to the old numbers and your post haven’t.

          Try running this:
          SELECT count(distinct(id)),count(id),count(distinct(menu_order)),count(menu_order) FROM `wp_posts` WHERE 1;

          It should return 4 numbers, all of them should be the same.

          If I’m reading it right “Duplicate entry ’0′ for key ‘PRIMARY’” means that one or more of the posts have their “menu_order” column – that which I use for the old post numbers – set to zero. If you’ve tried to run the line you pasted more than once – that is expected because it sets that field to NULL (or 0 in this case).

          • PerfectCr says:

            So basically, it’s not a big deal? I ignored it and started working on my site and everything appears fine. The only thing that big translate well were Tags, which I dont really care about anyway. :) THANK YOU again!

            • Jon says:

              Well that line is important, but if your post id’s are the same… then it probably failed out on a single record (which probably isn’t a big loss).

              Pull up one of your old posts. the S9y URL will be something like /archives/123-post-name-here.html

              Now goto WP /?p=123 — If the post is the same before and after – you’re good to go (I find generally the most recent posts are the most likely to be “out of sync”). Also check if your comments on one of the S9y posts show up on the right WP post. If so… they you’re good to go.

  11. [...] around for a while and has been patched/modified by various people. Luckily I found version 1.4, which got updated very recently (June 2010). For some reason it didn’t work for me when I [...]

  12. [...] Google-fu, I ended up at Snowulf.com.  Jon there had taken an earlier version of the importer and updated it to version 1.4. Just let me say Jon was extremely helpful.  I bothered him on Twitter for well over a week as [...]

  13. Robin says:

    I imported categories, users fine but posts gave me the Fatal Error: Call to a member function _real_escape() /path/to/html/wp-includes/wp-db.php on line 849

    I’m running the latest WordPress. Could that be the problem?

    Thanks,
    Robin

Leave a Reply