From f44de66de701b1775e0f8b017f2ff2c1603cd5f8 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 5 Nov 2025 18:16:30 +0100 Subject: [PATCH] User/Profiles * speed up load of user profiles --- includes/dbtypes/profile.class.php | 2 +- includes/user.class.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/dbtypes/profile.class.php b/includes/dbtypes/profile.class.php index cf75fcb1..fe109400 100644 --- a/includes/dbtypes/profile.class.php +++ b/includes/dbtypes/profile.class.php @@ -662,7 +662,7 @@ class LocalProfileList extends ProfileList protected string $queryBase = 'SELECT p.*, p.`id` AS ARRAY_KEY FROM ?_profiler_profiles p'; protected array $queryOpts = array( 'p' => [['g'], 'g' => 'p.`id`'], - 'ap' => ['j' => ['?_account_profiles ap ON ap.`profileId` = p.`id`', true], 's' => ', (IFNULL(ap.`ExtraFlags`, 0) | p.`cuFlags`) AS "cuFlags"'], + 'ap' => ['j' => ['?_account_profiles ap ON ap.`profileId` = p.`id`', true], 's' => ', (IFNULL(ap.`extraFlags`, 0) | p.`cuFlags`) AS "cuFlags"'], 'atm' => ['j' => ['?_profiler_arena_team_member atm ON atm.`profileId` = p.`id`', true], 's' => ', atm.`captain`, atm.`personalRating` AS "rating", atm.`seasonGames`, atm.`seasonWins`'], 'at' => [['atm'], 'j' => ['?_profiler_arena_team at ON at.`id` = atm.`arenaTeamId`', true], 's' => ', at.`type`'], 'g' => ['j' => ['?_profiler_guild g ON g.`id` = p.`guild`', true], 's' => ', g.`name` AS "guildname"'] diff --git a/includes/user.class.php b/includes/user.class.php index e8028229..a854b225 100644 --- a/includes/user.class.php +++ b/includes/user.class.php @@ -780,7 +780,10 @@ class User if (self::$profiles === null) { - $conditions = [['OR', ['user', self::$id], ['ap.accountId', self::$id]]]; + $ap = DB::Aowow()->selectCol('SELECT `profileId` FROM ?_account_profiles WHERE `accountId` = ?d', self::$id); + + // the old approach ['OR', ['user', self::$id], ['ap.accountId', self::$id]] caused keys to not get used + $conditions = $ap ? [['OR', ['user', self::$id], ['id', array_keys($ap)]]] : ['user', self::$id]; if (!self::isInGroup(U_GROUP_ADMIN | U_GROUP_BUREAU)) $conditions[] = [['cuFlags', PROFILER_CU_DELETED, '&'], 0];