Skip to content

Commit

Permalink
Add any missing User Attribute Records during upgrade process
Browse files Browse the repository at this point in the history
Fix for #1128
  • Loading branch information
eSilverStrike committed Jun 27, 2022
1 parent 0633c21 commit e721c1c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sql/updates/mysql_2.2.1_to_2.2.2.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,18 @@ function update_CombineUserTables222()
LEFT JOIN {$_TABLES['userindex']} AS x ON c.uid = x.uid
LEFT JOIN {$_TABLES['userinfo']} AS f ON c.uid = f.uid
LEFT JOIN {$_TABLES['userprefs']} AS p ON c.uid = p.uid";
DB_query($sql);
DB_query($sql);

// Due to unknown errors in the past users may not have a usercomment record so the above statement would not have added a user attribute record
// Add a user attribute record for any user that is missing one (as it is required)
$sql = "INSERT INTO {$_TABLES['user_attributes']}
SELECT u.uid, 'nested', 'ASC', 100,
'-', 0, 0,
'', '', '', 0, 0, 0,
0, 1, '', 1, 1, 1
FROM {$_TABLES['users']} u
WHERE u.uid NOT IN (SELECT uid FROM {$_TABLES['user_attributes']})";
DB_query($sql);

/* Converted commented code to above SQL query to improve speed
$sql3 = <<<SQL
Expand Down
10 changes: 10 additions & 0 deletions sql/updates/pgsql_2.2.1_to_2.2.2.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,16 @@ function update_CombineUserTables222()
LEFT JOIN {$_TABLES['userprefs']} AS p ON c.uid = p.uid";
DB_query($sql);

// Due to unknown errors in the past users may not have a usercomment record so the above statement would not have added a user attribute record
// Add a user attribute record for any user that is missing one (as it is required)
$sql = "INSERT INTO {$_TABLES['user_attributes']}
SELECT u.uid, 'nested', 'ASC', 100,
'-', 0, 0,
'', '', '', 0, 0, 0,
0, 1, '', 1, 1, 1
FROM {$_TABLES['users']} u
WHERE u.uid NOT IN (SELECT uid FROM {$_TABLES['user_attributes']})";
DB_query($sql);

/* Converted commented code to above SQL query to improve speed
$sql3 = <<<SQL
Expand Down

0 comments on commit e721c1c

Please sign in to comment.