HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Problems creating Wordpress XML file for import

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#102989 (In Topic #20174)
Avatar

Well-settled

Let's actually describe what is needed

The toasted disk drive gives me a chance to start over here. (Sorry about that.) I have written a script to generate a file in WordPress XML format. I can now reliably cause ocP to crash during the import (on a TODO in news2.php). Unless I am missing something, there is no real description of what is needed.
The "easy part" is actual blog posts and it appears that the RSS format is all that is needed. But, even there, there seem to be differences. For example, in some places the date is in a format such as "Sun, 3 Feb 2014 01:02:03 GMT" but in others in a totally different format.
The bigger mystery is how to specify comments. I have spent a lot of time guessing. I can continue to guess and read the ocP code but, at this point I actually am producing something that looks right to me but clearly not ocP.
What I am looking for is "the best" format to generate, what is required, what is not. I am willing to put some effort into writing this up but I would like to avoid reinventing what is already described.
What I actually doing is reading pages from an existing Drupal 5 site and massaging them into the needed XML.
Back to the top
 
Posted
Rating:
#102990
Avatar

Hmm, those TODO's in news2.php should not have been there, that's a bug. Each of the them should be a '' instead. I think the error never got triggered as in practice the comment_id/comment_type were always there in test data.

If you send me something you think should work (chris@ocportal.com), I will give it a shot as test data.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#102996
Avatar

Okay, so it generally works, but there are 3 bugs in where it tries to derive defaults. Nobody reported before as that code never triggers for a real Wordpress import.

This diff fixes our issues…

Code (diff)

diff --git a/sources/news2.php b/sources/news2.php
index b5f7301..46bfdf6 100644
--- a/sources/news2.php
+++ b/sources/news2.php
@@ -397,15 +397,15 @@ function import_rss()
 
                                        $comment_content=import_foreign_news_html($comment['COMMENT_CONTENT']);
                                        $comment_author=array_key_exists('COMMENT_AUTHOR',$comment)?$comment['COMMENT_AUTHOR']:do_lang('GUEST');
-                                       $comment_parent=array_key_exists('COMMENT_PARENT',$comment)?$comment['COMMENT_PARENT']:'';
-                                       $comment_date_gmt=array_key_exists('COMMENT_DATE_GMT',$comment)?$comment['COMMENT_DATE_GMT']:date('D/m/Y H:i:s',time());
+                                       $comment_parent=array_key_exists('COMMENT_PARENT',$comment)?$comment['COMMENT_PARENT']:NULL;
+                                       $comment_date_gmt=array_key_exists('COMMENT_DATE_GMT',$comment)?$comment['COMMENT_DATE_GMT']:date('d-m-Y H:i:s',time());
                                        $author_ip=array_key_exists('COMMENT_AUTHOR_IP',$comment)?$comment['COMMENT_AUTHOR_IP']:get_ip_address();
                                        $comment_approved=array_key_exists('COMMENT_APPROVED',$comment)?$comment['COMMENT_APPROVED']:'1';
                                        $comment_id=array_key_exists('COMMENT_ID',$comment)?$comment['COMMENT_ID']:'';
                                        $comment_type=array_key_exists('COMMENT_TYPE',$comment)?$comment['COMMENT_TYPE']:'';
 
-                                       $comment_author_url=array_key_exists('COMMENT_AUTHOR_URL',$comment)?$comment['COMMENT_AUTHOR_URL']:TODO;
-                                       $comment_author_email=array_key_exists('COMMENT_AUTHOR_EMAIL',$comment)?$comment['COMMENT_AUTHOR_EMAIL']:TODO;
+                                       $comment_author_url=array_key_exists('COMMENT_AUTHOR_URL',$comment)?$comment['COMMENT_AUTHOR_URL']:'';
+                                       $comment_author_email=array_key_exists('COMMENT_AUTHOR_EMAIL',$comment)?$comment['COMMENT_AUTHOR_EMAIL']:'';
 
                                        $comment_add_date=strtotime($comment_date_gmt);
                                        if ($comment_add_date>time()) $comment_add_date=time();
 

and parenting is done like…

Code

<wp:comment>
<wp:comment_id>123</wp:comment_id>
<wp:comment_author><![CDATA[...]]></wp:comment_author>
<wp:comment_date>Fri, 04 Apr 2014 16:49:00</wp:comment_date>
<wp:comment_content>...</wp:comment>
<wp:comment>
<wp:comment_parent>123</wp:comment_parent>
<wp:comment_author><![CDATA[...]]></wp:comment_author>
<wp:comment_date>Sun, 06 Apr 2014 13:14:00</wp:comment_date>
<wp:comment_content>...</wp:comment_content>
</wp:comment>


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#102997
Avatar

Well-settled

OK, this looks good. I actually did fix those two lines like that but things still blew up – probably for the lack of one of the other fields.
Once I have "all the answers" I will write this up. Some things will come up (for example, is date or gmt date what is needed) but it should be easier for you to take my draft and comment on it.

Thanks.
Back to the top
 
Posted
Rating:
#102999
Avatar

Well-settled

Chris: one more question. Is there a "comment title"? I don't see anything defined or in a WP XML export but Drupal has this.
Back to the top
 
Posted
Rating:
#103001
Avatar

We do, so you'd have to hack the code for us to import it.

Look at this in news2.php:

Code

'', // Would be post title


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: