Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting user information after adding the user to additional user groups.
#1
Hello,

I have integrated MyBB into my laravel application.

Everything works fine, however, when i add a user to additional usergroups the load time is from 18-20 seconds compared to 0.03 seconds when the user is not added to an additional user group.

Is there any way to work around this, or am I doing anything wrong.

This is my code:

	function __construct(){
        # Initialize MyBB Global Functions
        define('IN_MYBB', NULL);
        global $mybb, $templates, $lang, $query, $db, $cache, $plugins, $displaygroupfields, $config;
        require_once '/home/**HIDDEN**/domains/forums.**HIDDEN**.com/public_html/global.php';

        # Set class variables from MyBB
        $this->mybb =& $mybb;
        $this->db =& $db;
        $this->cache = $cache;
        $this->plugins =& $plugins;
        $this->lang =& $lang;
        $this->config =& $config;

        # Set Admin Dir Variable
        define('MYBB_ADMIN_DIR', MYBB_ROOT.$this->config['admin_dir'].'/');

        # I dont even know what this is
        define('NON_FATAL', false);
    }

    function isLoggedIn(){
        if($this->mybb->user['uid'] != 0){
            # user is logged in, return some data
            $data = [
                'uid' => $this->mybb->user['uid'],
                'username' => $this->mybb->user['username'],
                'email' => $this->mybb->user['email'],
                'avatar' => ltrim($this->mybb->user['avatar'], $this->mybb->user['avatar'][0]),
                'avatardimensions' => $this->mybb->user['avatardimensions'],
                'usergroup' => $this->mybb->user['usergroup'],
                'additionalgroups' => $this->mybb->user['additionalgroups'],
                'displaygroup' => $this->mybb->user['displaygroups'],
                'usertitle' => $this->mybb->user['usertitle'],
                'regdate' => $this->mybb->user['regdate'],
                'lastactive' => $this->mybb->user['lastactive'],
                'lastvisit' => $this->mybb->user['lastvisit'],
                'lastpost' => $this->mybb->user['lastpost'],
                'signature' => $this->mybb->user['signature'],
                'reputation' => $this->mybb->user['reputation'],
                'ismoderator' => $this->mybb->user['ismoderator'],
                'logoutkey' => $this->mybb->user['logoutkey'],
            ];

            return $data;
        }else{
            return false;
        }

When i don't have any additional usergroups, this is what it returns:
Array
(
    [uid] => 1
    [username] => ** Hidden **
    [email] => ** Hidden **
    [avatar] => /uploads/avatars/avatar_1.png?dateline=1567539829
    [avatardimensions] => 100|100
    [usergroup] => 4
    [additionalgroups] => 
    [displaygroup] => 
    [usertitle] => ** Hidden **
    [regdate] => 1566247201
    [lastactive] => 1569766933
    [lastvisit] => 1569764710
    [lastpost] => 1567539549
    [signature] => ** Hidden **
    [reputation] => 0
    [ismoderator] => 1
    [logoutkey] => 3ce19c82e94fd1ab4c37be6d5623b5c3
)
Page load time: 0.043290853500366 second(s).

When i add the user to only one additional user group this is what it returns:

Array
(
    [uid] => 1
    [username] => ** Hidden **
    [email] => ** Hidden **
    [avatar] => /uploads/avatars/avatar_1.png?dateline=1567539829
    [avatardimensions] => 100|100
    [usergroup] => 4
    [additionalgroups] => 23
    [displaygroup] => 
    [usertitle] => ** Hidden **
    [regdate] => 1566247201
    [lastactive] => 1569766933
    [lastvisit] => 1569764710
    [lastpost] => 1567539549
    [signature] => ** Hidden **
    [reputation] => 0
    [ismoderator] => 1
    [logoutkey] => 3ce19c82e94fd1ab4c37be6d5623b5c3
)
Page load time: 20.001002073288 second(s).

If i add the user to even more additonal user groups  it takes even longer.

If there is no way to fix this I am forced to store user data in a seperate database(laravels database) using cron jobs because this makes every single page for logged in users load for atleast 20 seconds if the user has more than one user group.

Thanks Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)