You are here

PHPNuke To Drupal Migration

While porting this site from Nuke (7.1) to Drupal (4.6.0 final), I had to create a custom script to get the job done. I'm making this available to the Drupal community as there is no other solution available (afaik) at present to accomplish this. This isn't necessarily a pretty solution, just a functional one ;)

The download link is further below this page (change the extension to .php before you run it).

Thus far the migration has been smooth, and I've noticed no issues. The only anomaly that I've come across is due to Drupal's inconsistency when it comes to using the auto_increment feature. But this shouldn't affect the site in any manner.

If you find this script useful, and would like to give back something in return, I recommend donating to the Drupal project.

Please feel free to add your comments on this page for the benefit of other users.

I have no issues with reusing / posting this script elsewhere, but I'd appreciate it if you always give credit and link back to this page. Please do not link directly to the attachment on this server, and link to this page instead.

The following updates to this script are also available. I have not tested any of them.. so caveat emptor and all that..

From the comments: jonhattan has created a module to handle this migration using Drupal's Batch API.

Cheers,
-K
Edits:

  • July 2005: Reattached the file as a ZIP file. The source file inside has a .phps extension which will need to be renamed to .php. The attachment below is only visible to authenticated users.
  • August 2006: Added updates list.
  • February 2007 License confirmation: This script is licensed under version 2 of the GPL.
  • February 2007 Added link to Waldo's update.
AttachmentSize
Package icon nuke2drupal_migrate.zip6.15 KB

Comments

I had have site at php-nuke 7.1 with russian encoding windows-1251. Now I trying to migrate to drupal, but drupal has code page ru-utf-8 and all information after inserting dump's data base of php-nuke into drupal's DB could not normally viewed at drupal pages.

What can I do?

[quote=wwwadim]I had have site at php-nuke 7.1 with russian encoding windows-1251. Now I trying to migrate to drupal, but drupal has code page ru-utf-8 and all information after inserting dump's data base of php-nuke into drupal's DB could not normally viewed at drupal pages.

What can I do?[/quote]

I am not entirely certain. But, to make an educated guess I suggest that you look into:

  • iconv: This is also available as a PHP function, and can be used to convert strings and entire files from one charset to another. So you could either add the conversion into the script above, or alternatively, export your database into an SQL file and convert the file into the desired charset.
  • ALTER TABLE: You could use this to convert your existing tables to UTF. Note that ALTER DATABASE will not work as it only sets the charset for *new* tables.

I hope that points you in the right direction :)
-K

I want to use ALTER TABLE and find out next query:

ALTER TABLE nuke_table CONVERT TO CHARACTER SET 'utf8';,

where nuke_table - for example nuke_stories table

I am trying to use it in SQL-query window in php-MyAdmin but I've got an sql syntax error 1064.
I am no good in MySQL. Maybe it is not really query that I used?
Could you help me, please.

Try it without the quotes around utf8.. Also, make sure that you have a compatible version of MySQL. As per that page, you need 4.1.2 for this.

I also recommend that you go with option 1 as in my last post. This link has a dodgy method of doing this as well as the iconv syntax at the bottom :)

If you still have issues, I suggest that you ask in the Drupal fora as I'm sure there will be a number users who have been in the same position as you are in now, and will be able to help you better :)

Best of luck,
Karthik.

I've tried the migrate.php script on my local setup, and it does work for the first 2 stories, and then ends. The stories do migrate to Drupal ok. But I have 99 stories to migrate. Any ideas on how to get it to keep on keeping on?

I mentioned this in a post on 27 March but no one has responded.

Thanks,
Peter

I don't know how to tell you this but... this script works!

I can confirm you that it is working very well from PHP-Nuke 7.5 to Drupal 4.6.3 without any changes.

I also used the link on the bottom of this page to convert some caracters from ISO-xxxx to utf-8 and it works.

Since at the beggining I did not knew how to transfert all the data to Drupal. I played around with Drupal and use another username. So here is a little trick for people who changed they username from PHP-Nuke to Drupal with this script. Go in Drupal, change your username to the old one, add the old username in the script at line 30, run the script, rename your username to the new name and voilà.

Oh, and also, you need to rename the file to migrate.php or the script will not work ;)

Thanks again for making this script available.

I'm sure everone else that was sick of dealing with security flaws and patches (and the various useless support sites) for nuke are very thankful for your contribution to the Drupal community. I know I am!

I've been a user for less than 1 day, and your script has made me a permanent user. Thanks again!

Has anyone tried this with 7.7 yet or know of any changes that need to be made specifically to the user migration piece?

Thanks!

Went ahead and did it anyway and it seemed to work great. Thanks!

Does anyone know if this would work with to migrate an installation of phpnuke 6.8?

Thanks!

Unsure. You can:

a)Take a database dump of your 6.8 site and test things out..

or

b) Upgrade your installation of nuke to 7.1 and then give it a shot.

Best of luck :)
-K

I have done a mashup of this script over at http://www.bizlabz.com/node/2 where I make several important changes to handle the new node_Revisions table structure amongst other things. I also wrote down some of my more exciting things that went wrong.

The moral of the story is to actually read all the way through the instructions. I skipped the part where you create the test entries into the database, and that was annoying to find later.

Thank you for the original code, and please continue improving it. My programming skills are kind of weak.

Cheers. For maintainability, the script needs to be completely rewritten to use Drupal's nodeAPI - the current script is just a quickly put together bunch of SQL statements :S Ideally, there ought to be an immigrate module to handle imports from a pluggable list of CMS-es .. One of these days, I might get around to writing it :|

-K

MySQL Error: Max ID for node_nid could not be retrieved

this is the error i m getting can u create a custom script for php nuke 7.8 or tell me some way i only need to move my stories

the user can be re-registered but i need to move atleast stories dude plz help me

MySQL Error: Max ID for node_counter could not be retrieved

this is the error i m getting

can u plz help me i dont need much to move user just make the stories migrate to drupal stories

i m using php nuke 7.8 plz help me

thanx

Hi,

I really don't remember much about this script, but you will probably need to look into the get_max_id() function and trace the call from there. You could also try commenting out the "else" block in the above mentioned function.

I don't recall the use of node_counter at all; please note that this was originally written for nuke 7.1. There are also a couple of updated versions of this script floating around on the net. You might want to have a look at those as well.

hth,
-K

I've added links to a couple of script updates in the main post. Please follow them and give it a shot.

Best of luck!
-K

- added options for custom phpnuke table prefixes (different from nuke_)
- default user name is now = uname (login), not just 'temp_name', as before
- replaced hard-coded links to 'migrate.php' with links to $_SERVER['PHP_SELF'], so that if you rename the script you don't have any problems with that
- now forum topics should not be promoted to the main page (changed 1 to 0 as hinted by Alexis)

nothing else changed/improved, sorry :)

description and file.

I made a slight change to the script. If a username in PHPNuke contains single quotes, the import will fail. This should fix it:

Changed:
$row->text = addslashes($row->text);

To:
$row->text = addslashes($row->text);
// Escape user names with ' in them
$row->name = addslashes($row->name);

Hello,

I have try all the migration script and none of them work. can someone help me please to convert my phpnuke site into drupal. I have the message :

Giving blank usernames a default value..
Default values set..(0 rows affected)
Transferring User Details to Drupal..
Users could not be added.

i am using phpnuke 7.1 - drupal 4.7 - mysqldatabase

tks in advance.

Florian

Although a number of 4.7 users have confirmed that it works fine, the script was originally written to migrate to 4.6. So I suggest that you install 4.6, migrate and then upgrade to 4.7.

I can't be of any more help I'm afraid; I hardly remember anything about the script as such.

Best of luck!
-K

...of what I'm now calling phpnuke2drupal-5.x-0.01-W is here.

Here are my changes:

  • imports from (a security-patched) Nuke 6.5 -> Drupal 5.1
  • imports story categories into Drupal taxonomy
  • incorporates phpnuke “Contributor writes…” into story
  • incorporates phpnuke admin story “note”
  • imports polls (does not import record of who already voted. You can easily “close” old phpnuke polls via Admin page. I left them open.)
  • imports poll comments
  • imports *anonymous* comments for stories, fora, & polls
  • imports anonymous forum posts
  • filters BBCode to make semi-compatible with Drupal BBCode module
  • uses Drupal 5.0 API. (Must be run from drupal root directory (/drupal-5/,
    for example))

Hope it helps someone out there. Actually, I hope someone else is able to get it running :) Works for me anyway.

W

Hi Waldo,

I tried your script but I always fail...
Everything looks good, it tells me how many users are about to migrate but if I click on migrate user I got this:

Migrating users:
Giving blank user names a default value (their login)
UPDATE nuke.nuke_users set name=username where name=''
Default values set..(0 rows affected)
Transferring User Details to Drupal..
INSERT into drupal.users(uid, name, pass, mail, created, status, init, data) SELECT @a:= 4 + 1 + user_id, username, user_password, user_email, UNIX_TIMESTAMP(), 1, user_email, 'a:1:{s:5:"roles";a:1:{i:0;s:1:"2";}}' FROM nuke.nuke_users WHERE 1=1 AND username != 'anonymous' AND username != 'admin'
Users could not be added.

What could be the problem?

Thanks for you help!

This is waldo.. I'm uploading a new version of the script with some improvements. I haven't looked at your problem specifically, but if the new version doesn't fix it, let me know.

The new version will be called phpnuke2drupal-5.x-0.02-W and I'm sending it to the guy running this site right now..

W

UPDATE nuke.nuke_users set name=username where name=''

This suggests you have a phpnuke user whose name is ''-- can you check your phpnuke database to see if such a user exists?

W

Pages