Skip to content

Commit

Permalink
fix: Flarum role names cannot be null
Browse files Browse the repository at this point in the history
Adds more inline docs for Flarum target role map.
See bug report: #45 (comment)
"FLA_groups -> name_plural cannot be null, name_singular cannot be null"
  • Loading branch information
linc committed Mar 3, 2024
1 parent 6613743 commit ac3ec6a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Target/Flarum.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,12 @@ protected function roles(ExportModel $ex): void
$ex->pruneOrphanedRecords('PORT_UserRole', 'UserID', 'PORT_User', 'UserID');

$query = $ex->dbImport()->table('PORT_Role')->select(
$ex->dbImport()->raw("(RoleID + 4) as id"), // Flarum reserves 1-3 & uses 4 for mods by default.
'Name as name_singular',
'Name as name_plural',
// Flarum reserves 1-3 & uses 4 for mods by default.
$ex->dbImport()->raw("(RoleID + 4) as id"),
// Singular vs plural is an uncommon feature; don't guess at it, just duplicate the Name.
$ex->dbImport()->raw('COALESCE(Name, CONCAT("role", RoleID)) as name_singular'), // Cannot be null.
$ex->dbImport()->raw('COALESCE(Name, CONCAT("role", RoleID)) as name_plural'), // Cannot be null.
// Hiding roles is an uncommon feature; hide none.
$ex->dbImport()->raw('0 as is_hidden')
);

Expand Down

1 comment on commit ac3ec6a

@linc
Copy link
Owner Author

@linc linc commented on ac3ec6a Mar 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will set roles with no name to have a name in the format role123 where the number is based on their roleID in the previous platform.

Please sign in to comment.