Skip to:
Content
Pages
Categories
Search
Top
Bottom

WP Database crashed/restored = BBP not showing topics/replies


  • Dean Scott
    Participant

    @chrusion

    Topic is brief description. This is the longer one.

    A mySQL database hiccup crashed our entire site (white screens of death – front and back ends). Unknown the cause. Link in recovery email didn’t work (still white screen), so I wiped and restored the database from a backup made via phpMyAdmin an hour before.
    Now that the DB is restored and the site working again, I found BBP 2.6.9 to be functioning everywhere EXCEPT displaying topics and replies. Forum and Topic lists display just fine. Enabling WP debug display gives the following when clicking on a topic in any given forum:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts FORCE INDEX (PRIMARY, post_parent) WHERE 1=1 AND (wp_posts.ID = 20986 OR wp_posts.post_parent = 20986) AND ((wp_posts.post_type = ‘topic’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘closed’ OR wp_posts.post_status = ‘tribe-ea-success’ OR wp_posts.post_status = ‘tribe-ea-failed’ OR wp_posts.post_status = ‘tribe-ea-schedule’ OR wp_posts.post_status = ‘tribe-ea-pending’ OR wp_posts.post_status = ‘tribe-ea-draft’ OR wp_posts.post_status = ‘private’ OR wp_posts.post_status = ‘hidden’)) OR (wp_posts.post_type = ‘reply’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘closed’ OR wp_posts.post_status = ‘tribe-ea-success’ OR wp_posts.post_status = ‘tribe-ea-failed’ OR wp_posts.post_status = ‘tribe-ea-schedule’ OR wp_posts.post_status = ‘tribe-ea-pending’ OR wp_posts.post_status = ‘tribe-ea-draft’ OR wp_posts.post_status = ‘private’ OR wp_posts.post_status = ‘hidden’))) ORDER BY wp_posts.post_date ASC LIMIT 0, 15

    HOWEVER, the post_parent key most certainly exists and all topic and reply post_types are intact with non-zero values in post_parent. It is NOT Primary, because ID is primary in order to be auto increment as required by WP for post and pages, etc.

    I tried to “reset” BBP by deleting it from WP plugins, hoping that reinstalling from WP plugin “store” (same version 2.6.9) would resync things. It did not.

    I did install WP Staging plugin to create a sandbox clone site to allow a developer of another unrelated plugin to investigate his work. This was done AFTER the live site issue being described. This cloned the database by creating new tables with a different prefix in the same DB as the live site. So, I don’t see how the two could be conflicting. The staging site also doesn’t display BBP’s posts/replies.

    I have ZERO ideas on what to do now, thus seeking HELP here. Site is https://comeandreason.com/forums/

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

  • Dean Scott
    Participant

    @chrusion

    Ugh. No editing of posts? Crazy. Anyway… forgot to select the error along with the query…. WordPress database error: [Key ‘post_parent’ doesn’t exist in table ‘wp_posts’]

    Like I said, ‘post_parent’ most certainly DOES EXIST! per copy/paste below from myPHPAdmin…

    1 ID Primary AUTO_INCREMENT
    2 post_author
    3 post_date
    4 post_date_gmt
    5 post_content
    6 post_title
    7 post_excerpt
    8 post_status
    9 comment_status
    10 ping_status
    11 post_password
    12 post_name
    13 to_ping
    14 pinged text
    15 post_modified
    16 post_modified_gmt
    17 post_content_filtered
    18 post_parent bigint(20) UNSIGNED
    19 guid
    20 menu_order
    21 post_type
    22 post_mime_type
    23 comment_count


    Robin W
    Moderator

    @robin-w

    I haven’t read this in detail (I’m just a guy sat in his kitchen trying to help others) but have you done this

    Dashboard>tools>forums>repair forums and run all of them, but one at a time!

    That should fix parent topics/replies


    Dean Scott
    Participant

    @chrusion

    I never knew those tools were there! Thanks.

    However, running each one individually did not fix the [Key ‘post_parent’ doesn’t exist in table ‘wp_posts’] error. Ugh.

    Probably because none of the repair descriptions match the situation at hand, eg. “run this if topic replies do not display.”

    The error “looks” like some sort of permissions thing, because, again, “post_parent” DOES exist.


    Dean Scott
    Participant

    @chrusion

    What is perplexing is that in the backend sidebar menu > Topic, ALL the OP topic posts are listed and open up for viewing/editing in the Edit page. SAME for the Replies menu.

    So, since the backend works, why is the frontend NOT showing the OP and reply posts? Why is BBP saying it can’t FIND the post_parent key when it appears it can in the backend?


    Dean Scott
    Participant

    @chrusion

    I installed and ran Robin’s Fix Import plugin from this thread: https://bbpress.org/forums/topic/topics-and-replies-not-showing-after-import/

    The results:

    Topics fixed…
    Replies fixed…
    All done….
    Total topics: 106
    Topics with no post_parent: 0
    Topics with no parent in post meta: 0
    Total replies: 663
    Replies with no post_parent: 0
    Replies with no parent in post meta: 0

    I do not see how this is possible. I’m looking at the database wp_posts and selecting by post_type = replies (and then topics) in phpMyAdmin. The post_parent key for post_type = replies has values matching the post_parent key value for each post_type = topic, AND the post_parent key value matches the ID key value for post_type = forum. Wherein does this warrant a finding of ZERO posts/replies?


    Dean Scott
    Participant

    @chrusion

    Oh… Wait… I read that wrong, didn’t I? Oops… so ALL topics and replies ARE paired with their respective post_parent key values. Nothing is wrong with the DB, so the question still remains: WHY is BBP unable to find post_parent key in the front end, but can in the back?


    Dean Scott
    Participant

    @chrusion

    I just discovered more at the end of the PHP error…

    LIMIT 0, 15 made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), apply_filters(‘template_include’), WP_Hook->apply_filters, bbp_template_include, apply_filters(‘bbp_template_include’), WP_Hook->apply_filters, bbp_template_include_theme_compat, BBP_Shortcodes->display_topic, bbp_get_template_part, bbp_locate_template, load_template, require(‘/plugins/bbpress/templates/default/bbpress/content-single-topic.php’), bbp_has_replies, WP_Query->__construct, WP_Query->query, WP_Query->get_posts

    Is this helpful?

    Yes, I’ve switched to 2024 theme AND deactivated all plugs, one-by-one. Same error.


    Robin W
    Moderator

    @robin-w

    hmmm…

    so have you actually looked at the database tables? or are you getting the status from my code?


    Dean Scott
    Participant

    @chrusion

    I’m looking directly at wp_posts table. post_parent key has matching values to post_type records (topics, replies) and verified by your code returning zero for any mismatches.

    I’ve also added a copy of my theme’s page.php (parent = Kyma, child = Frontech), renamed it bbpress.php, and put it in both parent and child root theme folders (unaltered, because there’s nothing in the theme interfering with the layout and placement of BBP). No change.


    Robin W
    Moderator

    @robin-w

    ok, not sure what to suggest.

    do you have a link to your site?


    Dean Scott
    Participant

    @chrusion

    It’s in the OP.

    Can you confirm what type of constraint is present on the post_parent column? The error uses the word KEY, which is a constrained column. Obviously, it can’t be a PRIMARY key, since ID is PRIMARY and AUTO INCREMENT, so post_parent set as UNIQUE, INDEX, or other?

    Now, I can run SQL in phpMyAdmin directly addressing post_parent, as in SELECT * FROM wp_posts WHERE post_parent != 0 AND post_type = topics OR post_type = replies;
    and the result is a screen full of all topics and replies.

    Yet this particular query syntax: SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts FORCE INDEX (PRIMARY, post_parent) throws the “doesn’t exist” error, so it must have something to do with the properties of post_parent not being an INDEX? So, HOW to make it one, per the above question.


    Dean Scott
    Participant

    @chrusion

    Field Type Collation Null Key Default Extra Privileges
    post_parent int(11) NULL YES — NULL — select,insert,update,references

    Is the column structure above correct for BBP? It seems that a blank/null value for Key might be the cause of the error in that the FORCE INDEX command works only on indexes (or keys) [right?], which the property of this column is not defined, thus throwing the error, correct?

    Should I experiment and set this column to be an INDEX key?


    Dean Scott
    Participant

    @chrusion

    Field       Type    Collation  Null  Key  Default  Extra  Privileges
    post_parent  int(11)   NULL     YES    —    NULL      —    select,insert,update,references 

    Robin W
    Moderator

    @robin-w

    I’m no mysql expert, but on my database the post parent is indexed

    http://www.rewweb.co.uk/wp-content/uploads/2019/07/Screenshot-2024-06-28-080147.png

    as are other fields

    I have no idea if clicking the bottom option lets you add this, but there must be a way, and agree this sounds like an issue that needs fixing


    Dean Scott
    Participant

    @chrusion

    Thanks! This is EXACTLY the info I was looking for. So, three of MY columns (post_parent, post_name, and post_author) have no keys. My wp_posts table does not have a type_status_date column. Might be added by another plugin.

    I will make a copy of the wp_posts table, set the above three columns to INDEX keys in the table copy, make a backup of the DB, rename wp_posts to wp_post_OLD and wp_posts_copy to wp_posts, and see if this resolves the SQL query error.

    BRB…

    WOO HOO!!!! My Forum is back in business! Posts and Replies are now displayed. YAY!

    Caveat: DO NOT select MULTIPLE columns to set as INDEX. It will group them in to one index/key and name it to the last box checked. Select one column at a time and set to INDEX. This will create the proper SQL query and name each column index key to the name of the column, as shown in the Indexes listing in linked image in the previous post.

    THANK YOU again, Robin, for your help! So much appreciated.

    I’ve learned my lesson… DO NOT restore a WP database from a WHM > Acronis backup! It doesn’t preserve keys/indexes. The Acronis Backup restore had an option to Auto Increment. I did not investigate what this meant, and left it disabled, resulting in all needed tables NOT having their primary keys auto incremented. This began trashing several tables as WP stuffed them with new records with IDs of zero, thus breaking the site via loads of database and PHP fatal errors due to “missing” variables not able to be found in the database, due to it becoming more corrupted by non-auto-incrementing ID columns and lack of primary and index keys.


    Robin W
    Moderator

    @robin-w

    wow – that’s great news, glad you are fixed, and as always I learn something from helping others 🙂

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