[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] Optimize XMPP user preference lookup by reusing get_user_preferences()
"luci \(@luciash\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a7c24963fabc_3819f74443940@gitlab-sidekiq-low-urgency-cpu-bound-v2-59f8c895df-7gz9z.mail> |
luci pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
4b13a4fa by ushindi bienvenu at 2026-08-12T07:31:34+00:00
[ENH] Optimize XMPP user preference lookup by reusing get_user_preferences()
---
* [ENH] Optimize XMPP user preference lookup by reusing get_user_preferences
See merge request tikiwiki/tiki!10698
- - - - -
1 changed file:
- lib/xmpp/xmpplib.php
Changes:
=====================================
lib/xmpp/xmpplib.php
=====================================
@@ -394,42 +394,41 @@ class XMPPLib extends TikiLib
public function get_user_connection_info($user)
{
- global $prefs;
+ global $user_preferences, $prefs, $tikilib;
+
+ $tikilib->get_user_preferences($user, [
+ 'xmpp_jid',
+ 'xmpp_password',
+ 'xmpp_custom_server_http_bind',
+ 'xmpp_custom_server_endpoint',
+ 'realName',
+ ]);
+
+ $u_jid = $user_preferences[$user]['xmpp_jid'] ?: $user;
+ $u_password = $user_preferences[$user]['xmpp_password'] ?: '';
+ $u_nickname = $user_preferences[$user]['realName'] ?: $user;
+ $u_httpBind = $user_preferences[$user]['xmpp_custom_server_http_bind'] ?? '';
+ $u_endpoint = $user_preferences[$user]['xmpp_custom_server_endpoint'] ?? '';
- $query = 'SELECT'
- . ' MAX(CASE WHEN `prefName`="xmpp_jid" THEN `value` END) AS `jid`,'
- . ' MAX(CASE WHEN `prefName`="xmpp_password" THEN `value` END) AS `password`,'
- . ' MAX(CASE WHEN `prefName`="xmpp_custom_server_endpoint" THEN `value` END) AS `endpoint`,'
- . ' MAX(CASE WHEN `prefName`="xmpp_custom_server_http_bind" THEN `value` END) AS `legacy_http_bind`,'
- . ' MAX(CASE WHEN `prefName`="realName" THEN `value` END) AS `nickname`'
- . ' FROM `tiki_user_preferences` WHERE `user`=?'
- . ' AND `prefName` IN ("xmpp_jid", "xmpp_password", "xmpp_custom_server_endpoint", "xmpp_custom_server_http_bind", "realName")';
-
- $query = $this->query($query, [$user]);
- $login = $query->fetchRow();
-
- if (empty($login['jid']) && $user) {
- $login['jid'] = $user;
- }
$info = [
'domain' => $this->server_host,
'http_bind' => $this->server_http_bind,
'websocket_url' => $prefs['xmpp_ws_url'] ?? '',
'custom_endpoint' => false,
- 'jid' => $prefs['xmpp_server_host'] ? JID::buildJid($login['jid'], $prefs['xmpp_server_host']) : '',
- 'password' => $login['password'] ?: '',
- 'username' => $login['jid'],
- 'nickname' => $login['nickname'] ?: $user,
+ 'jid' => $prefs['xmpp_server_host'] ? JID::buildJid($u_jid, $prefs['xmpp_server_host']) : '',
+ 'password' => $u_password,
+ 'username' => $u_jid,
+ 'nickname' => $u_nickname,
];
- $jid_parts = JID::parseJid($login['jid']);
+ $jid_parts = JID::parseJid($u_jid);
if ($jid_parts) {
- $info['jid'] = $login['jid'];
+ $info['jid'] = $u_jid;
$info['username'] = $jid_parts['node'];
$info['domain'] = $jid_parts['domain'];
- $endpoint = trim($login['endpoint'] ?: $login['legacy_http_bind'] ?: '');
+ $endpoint = trim($u_endpoint ?: $u_httpBind ?: '');
if ($endpoint) {
$transportOptions = $this->getEndpointTransportOptions($endpoint);
if ($transportOptions) {
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/4b13a4fa73b83e04a711d978d5bcb9d94f6b4f94
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/4b13a4fa73b83e04a711d978d5bcb9d94f6b4f94
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs