Archive for August, 2009

I finally decided to abandon phpWebLog which I’ve been using for nearly a decade now as the primary blogging/content management tool not only for my personal blogs, but also for my wife’s consulting firm, and several nonprofit organizations that I set up a website for.

Why did I move?  phpWebLog was a great choice when I started using it, in April of 2001.  At that time, the popular alternative seemed to be phpNuke but it’s community was busy exploding into a bunch of subprojects, and all of them seemed like they were far too heavyweight for the simple things I had in mind.

By contrast, phpWebLog was small and lightweight, and it was clear that I could understand all of the phpWebLog code pretty quickly, and bend it to my needs.  As it turns out, I modified heavily along the way, and now have an incompatible variant that is forked from that ancient release I started with in 2001.  For example, when podcasting caught my fancy in 2006, I added code to automatically cross-post show notes to the blog when adding them to the podcast directory.

Today, the heavyweight tool that’s too complicated to use is now Drupal, while phpNuke and phpWebLog are mostly forgotten.  I’m still trying to avoid overkill tools that cost me far more effort to learn than they’re worth.

But what’s wrong is that now the look of the old phpWebLog is starting to feel ugly and dated, and it’s hard to add new functionality in, while modern systems have a useful plugin architecture.  Too many simple things are hard to change in phpWebLog or are brittle.  So it’s time to migrate to something else, where I can spend my time writing the blog post, not writing the code on the server to support a post.

On the other hand, I am willing to invest a little in moving content between two systems.

WordPress is well supported, has a vibrant ecosystem around it for plugins and themes, is GPL, and is written in PHP, a language I know well.

So I installed WordPress and began to puzzle out how to insert my old content from phpWebLog into WordPress directly (mucking around with sql queries in the background).   I don’t recall which parts of phpWebLog I’ve extended and updated. It’s possible my phpWebLog schema is no longer similar enough to what you get now that this is useful to anyone.  The trickiest part of all of this is that the “category” id is right in the post table for phpWebLog but for WordPress category is indirectly bound to the post via the taxonomy table in WordPress.

This blog will focus just on high tech and software development.  So, while I was at it, I also split some of the old categories and their posts off into a separate wordpress blog (which will remain at nothingtodeclare.com), and only brought a few categories to this one.  And certain categories of content and their posts were just discarded altogether.  You can find the missing content at archive.org if you need it.

I thought about building a complete http referrer map in .htaccess, which I have done in the past but decided against that, partly because of the namespace collisions with some of the php files between phpWebLog and WordPress.  Besides, now that my parents have both passed away, there’s no one alive with bookmarks into any of my content.

Here’s the basic SQL that does the bulk migration.  I’ve left out the additional SQL that trimmed out certain categories and posts for each destination.  Comments inline, of course.

-- the phpWebLog tables are prefixed with t_
-- the wordpress tables are prefixed with wp_

-- copy over the table which contains the "categories"  (topics in phpWebLog).
-- note that we preserve the numerical value of the topic ids.
-- there's a lowercase version of the topic name that wordpress wants.
TRUNCATE TABLE `wp_terms` ;
INSERT INTO `wp_terms` (`term_id`, `name`, `slug`)
SELECT `Rid`, `Topic`, REPLACE(LOWER(`Topic`),' ','-')
FROM `T_Topics` ;

-- the taxonomy table points to the terms, and is pointed to by the relations table later.
TRUNCATE `wp_term_taxonomy`;
INSERT INTO `wp_term_taxonomy` ( `term_taxonomy_id`, `term_id`, `taxonomy`, `parent`, `count` )
SELECT `Rid`, `Rid`, 'category', 0, 0
FROM `T_Topics`;

-- we're going to copy the stories over, into the posts table.
-- phpWebLog required some quoting with the backslash that WordPress does not.
-- we try to preserve the original post dates and the last edit dates.
-- use phpWebLog Rid as the guid which is necessary later.
-- assumes that all the imported posts are from the admin post_author=1
TRUNCATE `wp_posts`;
TRUNCATE `wp_postmeta`;
INSERT INTO `wp_posts` ( `post_author`, `post_date`, `post_date_gmt`,
 `post_content`, `post_title`,
 `post_excerpt`, `post_name`,
 `post_modified`, `post_modified_gmt`, `guid` )
SELECT 1, `Birthstamp`, `Birthstamp`,
 REPLACE(`Content`,'\\','') , REPLACE(`Heading`,'\\',''),
 REPLACE(`Summary`,'\\','') , REPLACE(`Heading`,'\\',''),
 `Timestamp`, `Timestamp`, `Rid`
FROM `T_Stories`;

-- in order to create the relation table which points into the taxonomy and the posts respectively.
-- we need to join the posts and stories on the Rid/Guid so we can get out the new post id and old topic id.
TRUNCATE TABLE `wp_term_relationships`;
INSERT INTO `wp_term_relationships` ( `object_id`, `term_taxonomy_id`, `term_order` )
SELECT w.ID, t.Topic, 0
FROM `T_Stories` AS t, `wp_posts` AS w
WHERE t.Rid = w.guid ;

-- now we need to update the counts in the taxonomy table for the number of articles
-- that belong to each topic.  We do a simple temporary table of id's and counts first
CREATE TEMPORARY TABLE p
SELECT `Topic`, COUNT(`Topic`) AS Count
FROM `T_Stories`
GROUP BY `Topic`;

-- now update the taxonomy table with the counts
UPDATE `wp_term_taxonomy` AS w , p
 SET w.count = p.Count
WHERE w.term_id = p.Topic ;

-- at this point, if you are lucky, you should be able to go see your content
-- in wordpress, and with the categories still hooked up to the articles

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Comments Off.