2
0
forked from Wavyzz/dolibarr

Perf. Do not load personal conf of user by default.

This commit is contained in:
Laurent Destailleur
2017-04-14 12:52:32 +02:00
parent 4818b1ba44
commit aabfc2f0db
3 changed files with 16 additions and 9 deletions

View File

@@ -522,7 +522,7 @@ if (! defined('NOLOGIN'))
exit; exit;
} }
$resultFetchUser=$user->fetch('', $login, '', 1, ($entitytotest ? $entitytotest : -1)); $resultFetchUser=$user->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1));
if ($resultFetchUser <= 0) if ($resultFetchUser <= 0)
{ {
dol_syslog('User not found, connexion refused'); dol_syslog('User not found, connexion refused');
@@ -579,7 +579,7 @@ if (! defined('NOLOGIN'))
$entity=$_SESSION["dol_entity"]; $entity=$_SESSION["dol_entity"];
dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG); dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG);
$resultFetchUser=$user->fetch('',$login,'',1,($entity > 0 ? $entity : -1)); $resultFetchUser=$user->fetch('', $login, '', 1, ($entity > 0 ? $entity : -1));
if ($resultFetchUser <= 0) if ($resultFetchUser <= 0)
{ {
// Account has been removed after login // Account has been removed after login
@@ -734,7 +734,7 @@ if (! defined('NOLOGIN'))
} }
/* /*
* Overwrite configs global by personal configs (Note: Some conf->global personal vars were overwrote by the user->fetch) * Overwrite some configs globals (try to avoid this and have code to use instead $user->conf->xxx)
*/ */
// Set liste_limit // Set liste_limit

View File

@@ -164,11 +164,11 @@ class User extends CommonObject
* @param int $id If defined, id to used for search * @param int $id If defined, id to used for search
* @param string $login If defined, login to used for search * @param string $login If defined, login to used for search
* @param string $sid If defined, sid to used for search * @param string $sid If defined, sid to used for search
* @param int $loadpersonalconf 1=also load personal conf of user (in $user->conf->xxx) * @param int $loadpersonalconf 1=also load personal conf of user (in $user->conf->xxx), 0=do not load personal conf.
* @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup. * @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup.
* @return int <0 if KO, 0 not found, >0 if OK * @return int <0 if KO, 0 not found, >0 if OK
*/ */
function fetch($id='', $login='',$sid='',$loadpersonalconf=1, $entity=-1) function fetch($id='', $login='', $sid='', $loadpersonalconf=0, $entity=-1)
{ {
global $conf, $user; global $conf, $user;
@@ -360,7 +360,7 @@ class User extends CommonObject
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
return -2; return -2;
} }
@@ -381,6 +381,11 @@ class User extends CommonObject
} }
$this->db->free($resql); $this->db->free($resql);
} }
else
{
$this->error=$this->db->lasterror();
return -3;
}
} }
return 1; return 1;

View File

@@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2015 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro.com> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro.com>
* *
@@ -65,7 +65,7 @@ $dirleft = "../core/menus/standard";
// Charge utilisateur edite // Charge utilisateur edite
$object = new User($db); $object = new User($db);
$object->fetch($id); $object->fetch($id, '', '', 1);
$object->getrights(); $object->getrights();
// Liste des zone de recherche permanentes supportees // Liste des zone de recherche permanentes supportees
@@ -81,9 +81,11 @@ $formadmin=new FormAdmin($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('usercard','globalcard')); $hookmanager->initHooks(array('usercard','globalcard'));
/* /*
* Actions * Actions
*/ */
$parameters=array('id'=>$socid); $parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');