Missing Post Broken Threads

 To find threads where the "first post" is missing from the mybb_posts table, you need to compare the firstpost ID recorded in the mybb_threads table against the actual records in the mybb_posts table.

When MyBB creates a thread, it stores the ID of the starting post in mybb_threads.firstpost. If that post was deleted or failed to write during a database operation, the thread becomes "broken."

SQL Query to List Broken Threads

Run this query in your SQL manager (like phpMyAdmin) to find all threads where the associated first post does not exist:

SQL
SELECT t.tid, t.subject, t.firstpost, t.dateline
FROM mybb_threads t
LEFT JOIN mybb_posts p ON t.firstpost = p.pid
WHERE p.pid IS NULL;

Explanation of the Query

  • LEFT JOIN: This looks at every row in your threads table and tries to find a matching ID in the posts table.

  • WHERE p.pid IS NULL: This filters the results to show only the threads where the matching post record was not found.

  • t.tid & t.subject: This helps you identify which specific forum topics are affected.


How to Fix Them

Once you have the list, you have two main ways to handle the data:

1. The Automated Way (Recommended)

Before manually deleting anything, try the built-in MyBB tool which is designed to fix counter and association issues:

  1. Go to your Admin CP.

  2. Navigate to Tools & Maintenance > Recount and Rebuild.

  3. Run Rebuild Threads. This will attempt to re-associate the correct firstpost and lastpost IDs.

2. The Manual Cleanup (If the posts are truly gone)

If the posts were accidentally deleted from the database and you cannot recover them, these threads are essentially "ghosts." You can remove them using SQL (be sure to backup your database first):

SQL
DELETE FROM mybb_threads 
WHERE firstpost NOT IN (SELECT pid FROM mybb_posts);

Note on Database Prefixes

If your database uses a custom prefix (like fcsapxmy_ which I noticed in your earlier SSH attempts), ensure you add that to the table names (e.g., fcsapxmy_threads).

Since you've been working on a database recovery/merge project, these "ghost threads" often happen when the mybb_threads table is imported but the corresponding mybb_posts table is either truncated or from an older backup.

Comments

Popular posts from this blog

Drop Table

Copy Post to forum

corn-bot.php