mybb / merge-system

The MyBB Merge System allows for easy merging of an existing forum (be it MyBB or another forum software) into a MyBB 1.8.x forum.
Other
34 stars 33 forks source link

MyBB's forums module: `parentlist` is not properly set for root categories (type c forum) #243

Closed yuliu closed 4 years ago

yuliu commented 4 years ago

Issue:

The parentlist field of a merged type c (category) forum is the old value from the old database. One potential bug I can find currently due to this issue for the final merged forum is about forum password:

then, no matter or not X has a password, it'll need a password for entering X.

Cause:

Since MyBB Merge Module doesn't have a categories module, all forums are merged by the forums module. In the MyBB's forums module, all data fields from the old database will be imported as what they are except that each forum's parent ID (pid) will be set to 0 for the cleanup() to work. However, none of them will take care of imported root categories.

There are two cleanup()s:

  1. re-create each forum's parent ID and parent list (parentlist) from MyBB's forums module;
  2. create a new category and re-arrange forums without a parent as child forums of it from base forums module.

In a proper MyBB installation, each type f forum is sorted as a child forum of a type c category forum, so in a MyBB merge, the second cleanup() will actually done nothing. While the first cleanup() will just exclude such root categories from being processed (import_pid will be 0 for them) https://github.com/mybb/merge-system/blob/bd7fd6b87d64ed568d6d28867e8c61e2ab38c607/boards/mybb/forums.php#L103 Anyway, the first cleanup() that make use of make_mybb_parent_list() will probably fail when processing a root category.

Solution:

Set parentlist field's value of a root category to its new fid after it's imported.

yuliu commented 4 years ago

Seems MyBB itself can't reset such values to correct ones at AdminCP by directly editing forum X's properties. The only way to fix this at AdminCP is to set forum X as a child forum of another forum and reset its parent to "None".

Looks like a well-run MyBB forum won't have such issues and the parentlist will only be updated upon changing a forum's parent https://github.com/mybb/mybb/blob/mybb_1822/admin/modules/forum/management.php#L1399 . Needs an issue of enhancement being created?

yuliu commented 4 years ago

For anyone who has already merged their MyBB forums and suffers from this bug, either of following methods for correcting would work: