[ticket/13713] Fix caching and priorities

PHPBB3-13713
This commit is contained in:
lavigor 2018-07-29 03:55:16 +03:00 committed by Marc Alexander
parent e616ec025c
commit 99d57e2743
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
3 changed files with 6 additions and 8 deletions

View file

@ -430,10 +430,6 @@ function getCaretPosition(txtarea) {
return _results;
}
function getNumberOfMatchedCachedNames(query) {
return getMatchedNames(query, cachedNames, cachedSearchKey).length;
}
function remoteFilter(query, callback) {
/*
* Do not make a new request until the previous one for the same query is returned
@ -456,7 +452,7 @@ function getCaretPosition(txtarea) {
* all relevant names have been fetched from the server
*/
if (cachedNamesForQuery &&
(getNumberOfMatchedCachedNames(query) >= mentionNamesLimit ||
(getMatchedNames(query, cachedNamesForQuery, cachedSearchKey).length >= mentionNamesLimit ||
cachedNamesForQuery.length < mentionBatchSize)) {
callback(cachedNamesForQuery);
return;
@ -494,7 +490,7 @@ function getCaretPosition(txtarea) {
sorter: function(query, items, searchKey) {
let i;
let len;
let highestPriorities = {u: 0, g: 0};
let highestPriorities = {u: 1, g: 1};
let _unsorted = {u: {}, g: {}};
let _exactMatch = [];
let _results = [];
@ -530,7 +526,7 @@ function getCaretPosition(txtarea) {
}
// Priority is calculated as the sum of priorities from different sources
_unsorted[item.type][item.id].priority += parseFloat(item.priority);
_unsorted[item.type][item.id].priority += parseFloat(item.priority.toString());
// Calculate the highest priority - we'll give it to group names
highestPriorities[item.type] = Math.max(highestPriorities[item.type], _unsorted[item.type][item.id].priority);

View file

@ -100,6 +100,8 @@ abstract class base_user implements source_interface
$user_ids[] = $row['user_id'];
}
$this->db->sql_freeresult($result);
// Load all user data with a single SQL query, needed for ranks and avatars
$this->user_loader->load_users($user_ids);

View file

@ -46,7 +46,7 @@ class topic extends base_user
* Results will be cached on a per-topic basis
*/
$query = $this->db->sql_build_query('SELECT', [
'SELECT' => 'u.username, u.user_id, t.topic_poster',
'SELECT' => 'u.username_clean, u.username, u.user_id, t.topic_poster',
'FROM' => [
USERS_TABLE => 'u',
],