Skip to:
Content
Pages
Categories
Search
Top
Bottom

Importing from Rainmaker; Topics’ post_parent = 0


  • Mike Costanzo
    Participant

    @mikecostanzo

    Hi there!

    I’m importing forums from Rainmaker into WordPress 4.8.2 and BBPress 2.5.14. On first glance, it looks like all has done well; a quick glance at a sample Forum, for example, tells me:

    “This forum contains 74 topics and 698 replies.”

    However, my Topics and Replies are not being “found” when a Forum is clicked on:

    “Oh bother! No topics were found here!”

    This appears to be because the post_parent in wp_posts for all these Topics and Replies is set to “0” in the database. And what’s worse, the “Repair” tools like “Recalculate the parent topic for each post” or “Recalculate the parent forum for each post” do not fix the problem; post_parent remains at value 0.

    The only way I have found to populate a Topic with the correct post_parent value is to open that topic in the Editor and click Publish. But since I have hundreds of Topics and thousands of Replies, manually saving all these Posts is hardly a workable solution.

    Does anyone know of a better way to solve this problem that doesn’t involve nearly infinite man-hours of drudgery and toil?

    Thanks in advance for any help you might be able to give. Long live BBPress!

Viewing 7 replies - 1 through 7 (of 7 total)

  • liderxlt
    Participant

    @liderxlt

    Hi Mike!
    I have the same problem. https://bbpress.org/forums/topic/do-not-see-the-topic-in-forum/
    Have you been able to solve the problem? I’m almost sure it’s the post_parent although I still can not assign a value to that paramenter. If I could do it with the others _bbp_forum_id, _bbp_reply_count, etc.

    When I’m doing the import I tried to force it with the function

    <?php
    function pariente($id){
      	include "wp-load.php";  
    	wp_get_post_parent_id( $id );
    	return ;
    }
    ?>

    But I have not succeeded

    Can you post the Rainmaker Database Schema somewhere? I’ll try and work it out for you


    liderxlt
    Participant

    @liderxlt

    Thanks for answering…
    As I mentioned in the open topic today https://bbpress.org/forums/topic/do-not-see-the-topic-in-forum/ What I did was prepare an xml file with the information to upload in the forums , topic and replies.

    I am using the plugin all import to load because it allows me to use cron tasks daily, not overload the server and not rewrite what is already loaded.

    I can do the import and visualize it correctly in the dashboard. The problem is that it is not displayed in the frontend. As far as I could see the post_parent of the topic is 0 … It must be equal to _bbp_forum_id.

    These are the parameters for the topic:
    _bbp_topic_id = 2231
    _bbp_forum_id = 2229
    _bbp_reply_count = 0
    _bbp_voice_count = 1
    _bbp_forum_parent_id = 2229

    Parameters replies:
    _bbp_topic_id = 2231
    _bbp_forum_id = 2229
    the_reply_parent_topic_id = 2229

    The other parameters, such as Post Status, are already automated.
    The good thing about the import plugin is that it allows you to introduce functions in import http://www.wpallimport.com/documentation/advanced/execute-php/

    I leave an extract of the topic export, there you can see how it takes the values but not the post_parent one

    <title>2586/15</title>
    		<link>http://localhost/expedientes/forums/topic/2586-15/</link>
    		<pubDate>Fri, 19 Jan 2018 03:22:16 +0000</pubDate>
    		<dc:creator><![CDATA[liderxlt]]></dc:creator>
    		<guid isPermaLink="false">http://localhost/expedientes/forums/topic/2586-15/</guid>
    		<description></description>
    		<content:encoded><![CDATA[<p style="text-align: center;"><strong><span style="text-align: start;">
    <strong>CAUSA:</strong> JUICIO EJECUTIVO]]></content:encoded>
    		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
    		<wp:post_id>2113</wp:post_id>
    		<wp:post_date><![CDATA[2018-01-19 00:22:16]]></wp:post_date>
    		<wp:post_date_gmt><![CDATA[2018-01-19 03:22:16]]></wp:post_date_gmt>
    		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
    		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
    		<wp:post_name><![CDATA[2586-15]]></wp:post_name>
    		<wp:status><![CDATA[publish]]></wp:status>
    		<wp:post_parent>0</wp:post_parent>
    		<wp:menu_order>0</wp:menu_order>
    		<wp:post_type><![CDATA[topic]]></wp:post_type>
    		<wp:post_password><![CDATA[]]></wp:post_password>
    		<wp:is_sticky>0</wp:is_sticky>
    		<category domain="topic-tag" nicename="2586-15"><![CDATA[2586/15]]></category>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_activity_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[10]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_author_ip]]></wp:meta_key>
    			<wp:meta_value><![CDATA[120.000.001]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_last_active_time]]></wp:meta_key>
    			<wp:meta_value><![CDATA[2016-02-03]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_reply_count]]></wp:meta_key>
    			<wp:meta_value><![CDATA[0]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_voice_count]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_wp_page_template]]></wp:meta_key>
    			<wp:meta_value><![CDATA[default]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_forum_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_forum_parent_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[post_parent]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[wp_get_post_parent_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[parent_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    	</item>

    Can it be solved with the correct function?
    Thanks for your time @netweb

    I’d still prefer to see the database schema, not data that’s already been parsed.

    From what I can see you’ve got various issues with that WXR data:

    <wp:post_type><![CDATA[topic]]></wp:post_type> <- topic shouldn’t be wrapped in ![CDATA[ / ]], I’m not sure if that or any other instances apart from content will be affected by this.

    _wp_page_template shouldn’t be included, if the post_type was page, then yes, but topic post type shouldn’t have a _wp_page_template meta key, again, I’ve no idea what the resultant behaviour of this would be, maybe ok, maybe not.

    • You have the following, which is correct: 1327 is the “forum ID”

    `
    <wp:postmeta>
    <wp:meta_key><![CDATA[_bbp_forum_id]]></wp:meta_key>
    <wp:meta_value><![CDATA[1327]]></wp:meta_value>
    </wp:postmeta>
    `

    • Just above the above, you have the following which is *not* correct, post_parent is *not* “post meta”, this should be in the wp_posts table and *not wp_postmeta

    `
    <wp:postmeta>
    <wp:meta_key><![CDATA[post_parent]]></wp:meta_key>
    <wp:meta_value><![CDATA[1327]]></wp:meta_value>
    </wp:postmeta>
    `

    • Closer to the top of your code you have <wp:post_parent>0</wp:post_parent>, this is where the post_parent should include that 1327 forum id.

    I suspect if you can get 1327 into that last item above you’ll be all set, or at least progressed somewhat, I’m pretty sure the repair tools will be able to recalculate the topic meta once that is in, so that’s another option to repair any meta issues.

    This might be a handy reference https://codex.wordpress.org/Database_Description

    Also checkout https://bbpress.trac.wordpress.org/ticket/2516, the file attached to that ticket is a pretty comprehensive WXR XML file of forum, topics, and replies layed out per the description in that ticket, it might be worth importing into a test site to help visualise the data when looking at the source of the XML file 🙂


    Mike Costanzo
    Participant

    @mikecostanzo

    Stephen,

    I’ll ask about the database schema, but since Rainmaker is proprietary software there’s no guarantee that I will be able to get it. Stay tuned.

    Also, liderxlt asked if I was able to solve the problem. The answer is… kind of. Since I’m copying all of my content over from one site to another, in my desperation I ended up hacking the WordPress Importer plugin so that it does not look for conflicts in the $post_parent value during import. This means that existing Post content will be overwritten if it shares the same $post_parent value, which would be an untenable solution in most cases. But since my content will be identical from site to site, I’m counting it as a necessary evil.

    Here is the snippet I excised from ‘wordpress-importer.php’:

    if ( $post_parent ) {		
    // if we already know the parent, map it to the new local ID		
    if ( isset( $this->processed_posts[$post_parent] ) ) {		
    $post_parent = $this->processed_posts[$post_parent];		
    // otherwise record the parent for later		
    } else {		
    $this->post_orphans[intval($post['post_id'])] = $post_parent;		
    $post_parent = 0;		
    }		
    }

    Of course, I made these changes as a separate (cloned) plugin, so I also had to update the register_importer function as well. That way I have access to the original Importer for non-Forum Posts and Pages.

    Like I said, this is a brute force hack, and not an elegant solution. If anyone has an elegant solution, I’m all ears. Thanks!


    Mike Costanzo
    Participant

    @mikecostanzo

    Stephen,

    As expected, Rainmaker was not willing to share their database schema:

    “We are more than happy to provide a database dump to our customers, yet we’re not able to share the Rainmaker database schema.”

    So, like I said before, if anyone has a more elegant solution than my cheesy hack, I’m all ears. Thanks!

    Thanks for the update, it was worth a try 😉

    Are you getting the correct post_parent now with those changes you’ve made?

    The notes I added in reply to @liderxlt above I’m pretty sure will get that sorted for @liderxlt

    I’m happy to look at any raw data or datebase dumps you have Mike, maybe a forum and/or topic WXR dump like that of which @liderxlt posted.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar