WordPress.org

Ready to get started?Download WordPress

Forums

ANNOUNCE: PMachine 2.0 import (v0.1) (26 posts)

  1. Xavier Borderie
    Member
    Posted 10 years ago #

    This is great!
    I've been waiting for this (hence my messages to Chritina, hoping to try myself at updating her script) and WP1.1-final in order to move my entire blog out of pM - looks like it's coming at long last! Thank you !
    One thing I wondered myself while thinking about starting from scratch : how do you deal with upload pictures ? Do you copy them and replace the code in the post, or is it up to the owner to edit the message accordingly, reuploading the file to the right place ?
    Try creating a Importers page on the Wiki, maybe that might launch a few more efforts, and gather some help around your own.
    Again: thank you!

  2. _mf_
    Member
    Posted 10 years ago #

    Glad to see you appreciate it. I only had 1 post among 157 containing a picture, so I was going to change it manually. However this can be tweaked for further automation.
    Right now I'd rather have the categories display problem fixed, perhaps later today I'll five it ashot unless someone's patience lasts less than mine :)
    Cheers!

  3. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    It would be great if this code complied with WP coding style guidelines so it could be easily integrated with the main release.

  4. _mf_
    Member
    Posted 10 years ago #

    I focused on error trapping and clear output, coding from 11pm to 5am with a baby crying didn't help. If anyone wants to throw some time at it, I can't do that right now.

  5. MrPeer
    Member
    Posted 10 years ago #

    Hello, i've got an error while importing posts & comments and I think it's a probleme with quotes.

  6. WillM
    Member
    Posted 10 years ago #

    _mf_ : the devs may not appreciate your efforts but I'm sure future users will :)

  7. _mf_
    Member
    Posted 10 years ago #

    WillM: In fact being asked to clean up my code to include it as part of the package indicates they *do* appreciate it :)
    Mr. Peer: Can you share the exact error messages as generated , including the SQL queries ? I have lots of single quotes in my french posts and imported without problem.

  8. MrPeer
    Member
    Posted 10 years ago #


    SELECT * FROM pm_weblog WHERE weblog='weblog'
    Calculating category equivalency for this post : pMachine (1) = WP (2)
    SELECT pm.id, wpc.category_nicename, pm.category, wpc.cat_ID, wpc.cat_name FROM wp_categories as wpc, pm_categories as pm WHERE (LOWER(REPLACE(pm.category,' ','-'))=wpc.category_nicename) AND (pm.id=1)
    Inserting post "Welcome"
    INSERT INTO wp_posts (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified) VALUES ('2', '2002-08-17 15:37:55', 'Bienvenue à moi, à vous... Voilà, c'est le premier message de ce blog... Whaou, quelle émotion... :) PS : Mettez des commentaires à mes posts, ça fera plaisir
    ', 'Welcome', '2', '', 'welcome', 'publish', '2002-08-17 15:37:55')
    Invalid query: You have an error in your SQL syntax near 'est le premier message de ce blog... Whaou, quelle émotion... :) PS : Mett' at line 4

  9. Xavier Borderie
    Member
    Posted 10 years ago #

    Problem seems to be with "c'est", obviously. Needs a check here...

  10. _mf_
    Member
    Posted 10 years ago #

    The SQL query has to be escaped so the single quotes don't break it. I'll be releasing a new version when time permits, unless someone sends me the fix before. Thx. for pointing that out, MrPeer!

  11. _mf_
    Member
    Posted 10 years ago #

    MrPeer: I think your PHP setup's magic_quotes settings may affect this. So, escaping the string may not be the best idea. Let's try this... change the lines around line 263 for this:
    $query = 'INSERT INTO $tableposts
    (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified)
    VALUES
    ("$post_author_id", "$posted", "$content", "$title", "$category", "$excerpt", "$post_name", "publish", "$posted")';
    Let us know if that works for you.

  12. MrPeer
    Member
    Posted 10 years ago #

    it doesn't work :
    Inserting post "Welcome"
    INSERT INTO $tableposts (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified) VALUES ("$post_author_id", "$posted", "$content", "$title", "$category", "$excerpt", "$post_name", "publish", "$posted")
    Invalid query: Table 'peer2.$tableposts' doesn't exist

  13. Xavier Borderie
    Member
    Posted 10 years ago #

    Problème de double-quote, je pense.
    Peer, m'est avis que c'est plutôt :
    $query = "INSERT INTO $tableposts
    (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified)
    VALUES
    ('$post_author_id', '$posted', '$content', '$title', '$category', '$excerpt', '$post_name', 'publish', '$posted')";
    (donc, inverser les " et les ' )
    Non ?

  14. _mf_
    Member
    Posted 10 years ago #

    Xibe: The current code is like what you posted.
    Mr. Peer: Don't know what I was thinking... This is untested but you can try it. Find these two lines:
    $content = $post['body'] . "<P />" . $post['more'];
    $excerpt = $post['blurb'];
    Change to:
    $content = addslashes($post['body'] . "<P />" . $post['more']);
    $excerpt = addslashes($post['blurb']);
    This may also be needed for the users descriptions. Change:
    $wp_description = $user['bio'] . "\nLocation: " . $user['location'] . "\nOccupation: " . $user['occupation'] . "\nInterests: " . $user['interests'] ;
    To:
    $wp_description = addslashes($user['bio'] . "\nLocation: " . $user['location'] . "\nOccupation: " . $user['occupation'] . "\nInterests: " . $user['interests'] );
    Reference:
    http://ca2.php.net/manual/en/function.addslashes.php
    I will be testing and posting a fix tonight.

  15. Xavier Borderie
    Member
    Posted 10 years ago #

    As far as I can understand, all posts are set to "publish" ? What about the pM posts that are not yet public ?
    (I have quite a few myself, waiting to be completed)
    Or did I read this excerpt the wrong way ?

  16. _mf_
    Member
    Posted 10 years ago #

    Yes, Xibe. That can easily be added as new functionality. I didn't have any "closed" posts in PM so I didn't implement it. I'll add that to the "to-do" list.

  17. Xavier Borderie
    Member
    Posted 10 years ago #

    That's great, thanks!

  18. _mf_
    Member
    Posted 10 years ago #

    Ok, so I've found a fix for the problem Mr. Peer was having. Turns out the PHP setup in his server must have magic_quotes_gpc to OFF. So, if I fixed all the queries to add slashes to them (so it works for him), it would not work for me (or others whose servers have this setting on). See:
    http://www.zend.com/manual/function.get-magic-quotes-gpc.php
    Check the comments in the code, I think it's self explanatory. I also added a feature to import all posts to a single user, if wanted. So version 0.3 of the pMachine 2.0 importer is online.
    If anyone's willing to test it again, pls. comment back here.

  19. MrPeer
    Member
    Posted 10 years ago #

    :(
    (with version 0.3)
    Inserting post "Welcome"
    INSERT INTO wp_posts (post_author, post_date, post_content, post_title, post_category, post_excerpt, post_name, post_status, post_modified) VALUES ('1', '2002-08-17 15:37:55', 'Bienvenue à moi, à vous... Voilà, c'est le premier message de ce blog... Whaou, quelle émotion... :) PS : Mettez des commentaires à mes posts, ça fera plaisir
    ', 'Welcome', '2', '', 'welcome', 'publish', '2002-08-17 15:37:55')
    Invalid query: You have an error in your SQL syntax near 'est le premier message de ce blog... Whaou, quelle émotion... :) PS : Mett' at line 4

  20. _mf_
    Member
    Posted 10 years ago #

    Mr. Peer,
    Can you share your phpinfo() results with us ?
    To solve your particular situation, you can always hard-code the addslashes() functions and remove the magic_quoets detection code.

  21. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    I would stripslashes and then use $wpdb->escape();

  22. Anonymous
    Unregistered
    Posted 10 years ago #

  23. _mf_
    Member
    Posted 10 years ago #

    Xavier: Yes, it's exactly that. and it specifically mentions:

    That's the golden rule. You should never have to stripslashes. Ever.

    In my code I test for the magic_quotes environment variable but for some reason it doesn't work in Mr.Peer's environment. I hope he can provide more details so we can make the current code work with this kind of exceptions.

  24. MrPeer
    Member
    Posted 10 years ago #

    http://mr.peer.tribalix.com/phpinfo.php
    I set magic_quote_runtime to on in my php.ini, restart apache, and try to import my PM base and it works
    BUT I've got an other problem : for each post, comments have the same author :|

  25. nclement
    Member
    Posted 9 years ago #

    Tried using the 03 version to import Pmachine into wordpress. When I run the script nothing happens. no error messges, no nothing.
    ?
    Neil

  26. _mf_
    Member
    Posted 9 years ago #

    As mentioned in the announcement, this was for pMachine 2.0 . It's GPL so you are free to do whatever you want. It'd be nice if you publish the results. I don't have any short-term plans to update the script as I don't use pMachine at all anymore.
    I believe there is another pMachine import script that supports 2.3 and the next (1.3) version of WP has new import functionality, you may want to check that.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.