2020-04-16, 07:44 PM
When copying a category, and the new category doesn't have a parent forum, there's an SQL error because the negative value -1 is inserted into the unsigned integer field pid.
[attachment=42757]
Steps:
-Copy forum
-Source forum: some category
-Destination forum: copy to new forum
-Copy Forum Settings and Properties: No
-Forum type: Category
-Title: something
-Parent forum: none
Since the correct pid for categories without a parent is 0 when adding a new category the value -1 is changed to 0 before it's saved to the database.
https://github.com/mybb/mybb/blob/featur...#L830-L833
But not when a category is copied.
Doing the same when copying a category would be an option to fix this error:
In admin/modules/forum/management.php lines 95-97:
change to:
[attachment=42757]
Steps:
-Copy forum
-Source forum: some category
-Destination forum: copy to new forum
-Copy Forum Settings and Properties: No
-Forum type: Category
-Title: something
-Parent forum: none
Since the correct pid for categories without a parent is 0 when adding a new category the value -1 is changed to 0 before it's saved to the database.
https://github.com/mybb/mybb/blob/featur...#L830-L833
But not when a category is copied.
Doing the same when copying a category would be an option to fix this error:
In admin/modules/forum/management.php lines 95-97:
if(!$errors)
{
$new_forum = $from_forum;
change to:
if(!$errors)
{
if ($mybb->input['pid'] < 0)
{
$mybb->input['pid'] = 0;
}
$new_forum = $from_forum;