diff options
author | Shitiz Garg <mail@dragooon.net> | 2014-06-22 18:13:01 +0530 |
---|---|---|
committer | Shitiz Garg <mail@dragooon.net> | 2014-06-27 17:48:36 +0530 |
commit | 6cf6ec33545ae3be2cd6f02f0c23f154006a29cf (patch) | |
tree | d4dd2de8cbe3a48ecc468141c1d22301be3c9745 /phpBB | |
parent | 6d23cc3a0e6c71bebc239d3b6ecd55f05f4b98d4 (diff) | |
download | forums-6cf6ec33545ae3be2cd6f02f0c23f154006a29cf.tar forums-6cf6ec33545ae3be2cd6f02f0c23f154006a29cf.tar.gz forums-6cf6ec33545ae3be2cd6f02f0c23f154006a29cf.tar.bz2 forums-6cf6ec33545ae3be2cd6f02f0c23f154006a29cf.tar.xz forums-6cf6ec33545ae3be2cd6f02f0c23f154006a29cf.zip |
[ticket/12759] Cache lang options for all fields while displaying
Previously these would be fetched one field at one time, causing a large
number of queries in case there were large number of custom profile fields
and/or unique number of users in areas such as viewing topics. Resolve this
by caching them at once when generating data for displaying them in templates.
PHPBB3-12759
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/config/profilefields.yml | 1 | ||||
-rw-r--r-- | phpBB/phpbb/profilefields/manager.php | 29 |
2 files changed, 29 insertions, 1 deletions
diff --git a/phpBB/config/profilefields.yml b/phpBB/config/profilefields.yml index ce2a84b12b..2ed8ca5600 100644 --- a/phpBB/config/profilefields.yml +++ b/phpBB/config/profilefields.yml @@ -5,6 +5,7 @@ services: - @auth - @dbal.conn - @dispatcher + - @profilefields.lang_helper - @request - @template - @profilefields.type_collection diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 490db0419a..a32baaac56 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -37,6 +37,12 @@ class manager protected $dispatcher; /** + * Profile fields language helper + * @var \phpbb\profilefields\lang_helper + */ + protected $lang_helper; + + /** * Request object * @var \phpbb\request\request */ @@ -74,6 +80,7 @@ class manager * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\db\driver\driver_interface $db Database object * @param \phpbb\event\dispatcher $dispatcher Event dispatcher object + * @param \phpbb\profilefields\lang_helper $lang_helper Language helper object * @param \phpbb\request\request $request Request object * @param \phpbb\template\template $template Template object * @param \phpbb\di\service_collection $type_collection @@ -82,11 +89,12 @@ class manager * @param string $fields_language_table * @param string $fields_data_table */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher $dispatcher, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) + public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\event\dispatcher $dispatcher, \phpbb\profilefields\lang_helper $lang_helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\di\service_collection $type_collection, \phpbb\user $user, $fields_table, $fields_language_table, $fields_data_table) { $this->auth = $auth; $this->db = $db; $this->dispatcher = $dispatcher; + $this->lang_helper = $lang_helper; $this->request = $request; $this->template = $template; $this->type_collection = $type_collection; @@ -385,6 +393,25 @@ class manager $vars = array('profile_row', 'tpl_fields', 'use_contact_fields'); extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data_before', compact($vars))); + if (!empty($profile_row)) + { + $field_ids = array(); + foreach ($profile_row as $ident_ary) + { + if (empty($field_ids[$ident_ary['data']['lang_id']])) + { + $field_ids[$ident_ary['data']['lang_id']] = array(); + + } + $field_ids[$ident_ary['data']['lang_id']][] = $ident_ary['data']['field_id']; + } + + foreach ($field_ids as $lang => $fields) + { + $this->lang_helper->get_option_lang($fields, $lang, false); + } + } + foreach ($profile_row as $ident => $ident_ary) { $profile_field = $this->type_collection[$ident_ary['data']['field_type']]; |