Perf: Sompe optimizations that reduce number of opened files

This commit is contained in:
Laurent Destailleur 2007-09-09 11:16:33 +00:00
parent 86eb3f096d
commit 3c5708ba7f
6 changed files with 103 additions and 71 deletions

View File

@ -114,6 +114,8 @@ $handle = opendir($dir);
if ($handle) if ($handle)
{ {
$var = true; $var = true;
// Loop on each module find in opened directory
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php')

View File

@ -29,8 +29,11 @@
\version $Revision$ \version $Revision$
*/ */
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
require_once("main.inc.php"); require_once("main.inc.php");
function llxHeader() function llxHeader()
{ {
global $user,$langs; global $user,$langs;

View File

@ -27,9 +27,16 @@
\brief Fichier de gestion de la popup de selection de date eldy \brief Fichier de gestion de la popup de selection de date eldy
\version $Revision$ \version $Revision$
*/ */
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
require_once("../conf/conf.php");
require_once("../master.inc.php"); require_once("../master.inc.php");
$langs->trans("main"); $langs->trans("main");
if(!isset($_GET["cm"])) $_GET["cm"]="shw"; if(!isset($_GET["cm"])) $_GET["cm"]="shw";

View File

@ -136,42 +136,58 @@ if (isset($_SERVER["HTTP_USER_AGENT"]))
} }
// Chargement des includes principaux // Chargement des includes principaux
require_once(DOL_DOCUMENT_ROOT ."/user.class.php"); if (! defined('NOREQUIREUSER')) require_once(DOL_DOCUMENT_ROOT ."/user.class.php");
require_once(DOL_DOCUMENT_ROOT ."/menu.class.php"); if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php");
require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php"); if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/html.form.class.php");
require_once(DOL_DOCUMENT_ROOT ."/lib/databases/".$conf->db->type.".lib.php"); if (! defined('NOREQUIREDB')) require_once(DOL_DOCUMENT_ROOT ."/lib/databases/".$conf->db->type.".lib.php");
if (! defined('NOREQUIRETRAN')) require_once(DOL_DOCUMENT_ROOT ."/translate.class.php");
if (! defined('NOREQUIRESOC')) require_once(DOL_DOCUMENT_ROOT ."/societe.class.php");
/* /*
* Creation objet $langs * Creation objet $langs
*/ */
require_once(DOL_DOCUMENT_ROOT ."/translate.class.php"); if (! defined('NOREQUIRETRAN'))
{
$langs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); // A mettre apres lecture de la conf $langs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); // A mettre apres lecture de la conf
}
/* /*
* Creation objet $db * Creation objet $db
*/ */
if (! defined('NOREQUIREDB'))
{
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name); $db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name);
if (! $db->connected) { if (! $db->connected)
{
dolibarr_print_error($db,"host=".$conf->db->host.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error); dolibarr_print_error($db,"host=".$conf->db->host.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error);
exit; exit;
} }
}
/* /*
* Creation objet $user * Creation objet $user
*/ */
if (! defined('NOREQUIREUSER'))
{
$user = new User($db); $user = new User($db);
}
/* /*
* Chargement objet $conf * Chargement objet $conf
*/ */
if (! defined('NOREQUIREDB'))
{
$conf->setValues($db); $conf->setValues($db);
}
/* /*
* Chargement langage par défaut * Chargement langage par défaut
*/ */
if (! defined('NOREQUIRETRAN'))
{
$langs->setDefaultLang($conf->global->MAIN_LANG_DEFAULT); $langs->setDefaultLang($conf->global->MAIN_LANG_DEFAULT);
$langs->setPhpLang($conf->global->MAIN_LANG_DEFAULT); $langs->setPhpLang($conf->global->MAIN_LANG_DEFAULT);
}
/* /*
* Pour utiliser d'autres versions des librairies externes que les * Pour utiliser d'autres versions des librairies externes que les
@ -222,7 +238,8 @@ if (defined("MAIN_MODULE_TELEPHONIE") && MAIN_MODULE_TELEPHONIE) require_once(FP
* Creation objet mysoc * Creation objet mysoc
* Objet Societe qui contient carac de l'institution géré par Dolibarr. * Objet Societe qui contient carac de l'institution géré par Dolibarr.
*/ */
require_once(DOL_DOCUMENT_ROOT ."/societe.class.php"); if (! defined('NOREQUIRESOC'))
{
$mysoc=new Societe($db); $mysoc=new Societe($db);
$mysoc->id=0; $mysoc->id=0;
$mysoc->nom=$conf->global->MAIN_INFO_SOCIETE_NOM; $mysoc->nom=$conf->global->MAIN_INFO_SOCIETE_NOM;
@ -272,7 +289,7 @@ $mysoc->adresse_full=$mysoc->adresse."\n".$mysoc->cp." ".$mysoc->ville;
$mysoc->logo=$conf->global->MAIN_INFO_SOCIETE_LOGO; $mysoc->logo=$conf->global->MAIN_INFO_SOCIETE_LOGO;
$mysoc->logo_small=$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; $mysoc->logo_small=$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL;
$mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
}
// Sert uniquement dans module telephonie // Sert uniquement dans module telephonie
$yesno[0]="no"; $yesno[0]="no";

View File

@ -31,14 +31,11 @@
\version $Revision$ \version $Revision$
*/ */
require_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
/** /**
\class Societe \class Societe
\brief Classe permettant la gestion des societes \brief Classe permettant la gestion des societes
*/ */
class Societe class Societe
{ {
var $db; var $db;
@ -982,6 +979,8 @@ class Societe
if ($this->id) if ($this->id)
{ {
require_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
$discount = new DiscountAbsolute($this->db); $discount = new DiscountAbsolute($this->db);
$discount->fk_soc=$this->id; $discount->fk_soc=$this->id;
$discount->amount_ht=price2num($remise,'MT'); $discount->amount_ht=price2num($remise,'MT');
@ -1012,8 +1011,10 @@ class Societe
{ {
if ($this->id) if ($this->id)
{ {
require_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
$discount = new DiscountAbsolute($this->db); $discount = new DiscountAbsolute($this->db);
$discount->fetch($id); $result=$discount->fetch($id);
$result=$discount->delete(); $result=$discount->delete();
return $result; return $result;
} }

View File

@ -28,6 +28,8 @@
\version $Revision$ \version $Revision$
*/ */
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
// C'est un wrapper, donc header vierge // C'est un wrapper, donc header vierge
function llxHeader() { } function llxHeader() { }