From 45529b14ff1eecdafe274f3790638e6ab7e5ec04 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Feb 2012 15:56:41 +0100 Subject: [PATCH 1/3] Removed dead code + Doxygen --- htdocs/core/menus/init_menu_auguria.sql | 1 - htdocs/core/menus/init_menu_smartphone.sql | 1 - htdocs/install/upgrade2.php | 202 +++++++++++++++++---- 3 files changed, 164 insertions(+), 40 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 781a6461b2c..4eefeb7512d 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -3,7 +3,6 @@ -- This file is loaded when a menu handler base is activated (auguria, etc..) -- --- V4.1 delete from llx_menu_const where fk_menu in (select rowid from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__); delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; -- diff --git a/htdocs/core/menus/init_menu_smartphone.sql b/htdocs/core/menus/init_menu_smartphone.sql index 8636d7ac607..482cb3cc6ff 100755 --- a/htdocs/core/menus/init_menu_smartphone.sql +++ b/htdocs/core/menus/init_menu_smartphone.sql @@ -3,7 +3,6 @@ -- This file is loaded when a menu handler base is activated (auguria, etc..) -- --- V4.1 delete from llx_menu_const where fk_menu in (select rowid from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__); delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__; -- diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 28866032f63..a9ed6be5a45 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -706,21 +706,14 @@ function migrate_paiements_orphelins_2($db,$langs,$conf) print ''; } -function migrate_paiements_orphelins_3($db,$langs,$conf) -{ - /* - select p.rowid from llx_paiement as p left join llx_paiement_facture as pf on pf.fk_paiement=p.rowid WHERE pf.rowid IS NULL AND (p.fk_facture = 0 OR p.fk_facture IS NULL) - Poru chaque rep, test si - select count(*) from llx_bank where rowid = obj->fk_bank - select count(*) from llx_bank_url where url_id = 128 and type='payment' - Si partout 0, on efface ligne de llx_paiement - */ - -} - -/* +/** * Mise a jour des contrats (gestion du contrat + detail de contrat) + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_contracts_det($db,$langs,$conf) { @@ -812,6 +805,13 @@ function migrate_contracts_det($db,$langs,$conf) print ''; } +/** + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void + */ function migrate_links_transfert($db,$langs,$conf) { print ''; @@ -888,8 +888,13 @@ function migrate_links_transfert($db,$langs,$conf) print ''; } -/* +/** * Mise a jour des date de contrats non renseignees + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_contracts_date1($db,$langs,$conf) { @@ -983,8 +988,13 @@ function migrate_contracts_date2($db,$langs,$conf) print ''; } -/* +/** * Mise a jour des dates de creation de contrat + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_contracts_date3($db,$langs,$conf) { @@ -1005,8 +1015,13 @@ function migrate_contracts_date3($db,$langs,$conf) print ''; } -/* +/** * Reouverture des contrats qui ont au moins une ligne non fermee + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_contracts_open($db,$langs,$conf) { @@ -1176,8 +1191,13 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf) } } -/* +/** * Mise a jour des totaux lignes de facture + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_price_facture($db,$langs,$conf) { @@ -1287,8 +1307,13 @@ function migrate_price_facture($db,$langs,$conf) print ''; } -/* +/** * Mise a jour des totaux lignes de propal + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_price_propal($db,$langs,$conf) { @@ -1387,8 +1412,13 @@ function migrate_price_propal($db,$langs,$conf) print ''; } -/* +/** * Mise a jour des totaux lignes de propal + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_price_contrat($db,$langs,$conf) { @@ -1488,8 +1518,13 @@ function migrate_price_contrat($db,$langs,$conf) print ''; } -/* +/** * Mise a jour des totaux lignes de commande + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_price_commande($db,$langs,$conf) { @@ -1597,8 +1632,13 @@ function migrate_price_commande($db,$langs,$conf) print ''; } -/* +/** * Mise a jour des totaux lignes de commande fournisseur + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_price_commande_fournisseur($db,$langs,$conf) { @@ -1706,8 +1746,13 @@ function migrate_price_commande_fournisseur($db,$langs,$conf) print ''; } -/* +/** * Mise a jour des modeles selectionnes + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_modeles($db,$langs,$conf) { @@ -1759,8 +1804,13 @@ function migrate_modeles($db,$langs,$conf) } -/* +/** * Correspondance des expeditions et des commandes clients dans la table llx_co_exp + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_commande_expedition($db,$langs,$conf) { @@ -1831,8 +1881,13 @@ function migrate_commande_expedition($db,$langs,$conf) print ''; } -/* +/** * Correspondance des livraisons et des commandes clients dans la table llx_co_liv + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_commande_livraison($db,$langs,$conf) { @@ -1919,8 +1974,13 @@ function migrate_commande_livraison($db,$langs,$conf) print ''; } -/* +/** * Migration des details commandes dans les details livraisons + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_detail_livraison($db,$langs,$conf) { @@ -2036,8 +2096,13 @@ function migrate_detail_livraison($db,$langs,$conf) print ''; } -/* +/** * Migration du champ stock dans produits + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_stocks($db,$langs,$conf) { @@ -2105,8 +2170,14 @@ function migrate_stocks($db,$langs,$conf) print ''; } -/* +/** * Migration of menus (use only 1 table instead of 3) + * 2.6 -> 2.7 + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_menus($db,$langs,$conf) { @@ -2181,9 +2252,14 @@ function migrate_menus($db,$langs,$conf) print ''; } -/* +/** * Migration du champ fk_adresse_livraison dans expedition * 2.6 -> 2.7 + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_commande_deliveryaddress($db,$langs,$conf) { @@ -2260,9 +2336,14 @@ function migrate_commande_deliveryaddress($db,$langs,$conf) print ''; } -/* +/** * Migration du champ fk_remise_except dans llx_facturedet doit correspondre a * lien dans llx_societe_remise_except vers llx_facturedet + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_restore_missing_links($db,$langs,$conf) { @@ -2414,8 +2495,13 @@ function migrate_restore_missing_links($db,$langs,$conf) print ''; } -/* +/** * Migration du champ fk_user_resp de llx_projet vers llx_element_contact + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_project_user_resp($db,$langs,$conf) { @@ -2506,8 +2592,13 @@ function migrate_project_user_resp($db,$langs,$conf) print ''; } -/* +/** * Migration de la table llx_projet_task_actors vers llx_element_contact + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_project_task_actors($db,$langs,$conf) { @@ -2593,8 +2684,13 @@ function migrate_project_task_actors($db,$langs,$conf) print ''; } -/* +/** * Migration des tables de relation + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcetype,$fk_target,$targettype) { @@ -2684,8 +2780,13 @@ function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcet print ''; } -/* +/** * Migrate duration in seconds + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_project_task_time($db,$langs,$conf) { @@ -2800,8 +2901,13 @@ function migrate_project_task_time($db,$langs,$conf) print ''; } -/* +/** * Migrate order ref_customer and date_delivery fields to llx_expedition + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_customerorder_shipping($db,$langs,$conf) { @@ -2896,8 +3002,13 @@ function migrate_customerorder_shipping($db,$langs,$conf) print ''; } -/* +/** * Migrate link stored into fk_expedition into llx_element_element + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_shipping_delivery($db,$langs,$conf) { @@ -3002,9 +3113,14 @@ function migrate_shipping_delivery($db,$langs,$conf) print ''; } -/* +/** * We try to complete field ref_customer and date_delivery that are empty into llx_livraison. * We set them with value from llx_expedition. + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_shipping_delivery2($db,$langs,$conf) { @@ -3082,8 +3198,13 @@ function migrate_shipping_delivery2($db,$langs,$conf) print ''; } -/* +/** * Migrate link stored into fk_xxxx into fk_element and elementtype + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_actioncomm_element($db,$langs,$conf) { @@ -3143,8 +3264,13 @@ function migrate_actioncomm_element($db,$langs,$conf) print ''; } -/* +/** * Migrate link stored into fk_mode_reglement + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void */ function migrate_mode_reglement($db,$langs,$conf) { From 8bcdfc8897e12600d757f80e7001797a53c66c9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Feb 2012 16:37:41 +0100 Subject: [PATCH 2/3] New: Add an error message when transactions are not closed. --- htdocs/admin/menus.php | 21 +++++++++++++++++++-- htdocs/core/db/mssql.class.php | 4 ++-- htdocs/core/db/mysql.class.php | 4 ++-- htdocs/core/db/mysqli.class.php | 4 ++-- htdocs/core/db/pgsql.class.php | 5 +++-- htdocs/core/db/sqlite.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 9 +++++---- 7 files changed, 35 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 9d56ca1ddba..9b63b00f195 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -74,6 +74,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1; // Initialize menu handlers + $errmsgs=array(); foreach ($listofmenuhandler as $key => $val) { // Load sql init_menu_handler.sql file @@ -83,10 +84,22 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can if (file_exists($fullpath)) { + $db->begin(); $result=run_sql($fullpath,1,'',1,$key); + if ($result > 0) + { + $db->commit(); + } + else + { + $errmsgs[]='Failed to initialize menu '.$key.'.'; + $db->rollback(); + } } } + $db->close(); + // We make a header redirect because we need to change menu NOW. header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -238,6 +251,9 @@ else print ''; +dol_htmloutput_errors($errmsgs); + + if (! isset($_GET["action"]) || $_GET["action"] != 'edit') { print '
'; @@ -245,7 +261,8 @@ if (! isset($_GET["action"]) || $_GET["action"] != 'edit') print '
'; } -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 04952615a0a..6975b8539ff 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -53,7 +53,7 @@ class DoliDBMssql var $database_name; //! Nom user base var $database_user; - //! 1 si une transaction est en cours, 0 sinon + //! >=1 if a transaction is opened, 0 otherwise var $transaction_opened; //! Derniere requete executee var $lastquery; @@ -242,7 +242,7 @@ class DoliDBMssql { if ($this->db) { - //dol_syslog(get_class($this)."::disconnect",LOG_DEBUG); + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); $this->connected=0; return mssql_close($this->db); } diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 73850cc70a5..b848531342a 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -53,7 +53,7 @@ class DoliDBMysql var $database_name; //! Nom user base var $database_user; - //! 1 si une transaction est en cours, 0 sinon + //! >=1 if a transaction is opened, 0 otherwise var $transaction_opened; //! Last executed request var $lastquery; @@ -269,7 +269,7 @@ class DoliDBMysql { if ($this->db) { - //dol_syslog(get_class($this)."::disconnect",LOG_DEBUG); + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); $this->connected=0; return mysql_close($this->db); } diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 5384dfb0517..4e715c2c756 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -53,7 +53,7 @@ class DoliDBMysqli var $database_name; //! Nom user base var $database_user; - //! 1 si une transaction est en cours, 0 sinon + //! >=1 if a transaction is opened, 0 otherwise var $transaction_opened; //! Last executed request var $lastquery; @@ -273,7 +273,7 @@ class DoliDBMysqli { if ($this->db) { - //dol_syslog(get_class($this)."::disconnect",LOG_DEBUG); + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); $this->connected=0; return mysqli_close($this->db); } diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index e340af866cc..50645c8701a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -51,7 +51,8 @@ class DoliDBPgsql var $database_selected; // 1 si base selectionne, 0 sinon var $database_name; //! Nom base selectionnee var $database_user; //! Nom user base - var $transaction_opened; // 1 si une transaction est en cours, 0 sinon + //! >=1 if a transaction is opened, 0 otherwise + var $transaction_opened; var $lastquery; var $lastqueryerror; // Ajout d'une variable en cas d'erreur @@ -439,7 +440,7 @@ class DoliDBPgsql { if ($this->db) { - //dol_syslog(get_class($this)."::disconnect",LOG_DEBUG); + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); $this->connected=0; return pg_close($this->db); } diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 52d6a05d4ce..32068b9c76c 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -53,7 +53,7 @@ class DoliDBSqlite var $database_name; //! Nom user base var $database_user; - //! 1 si une transaction est en cours, 0 sinon + //! >=1 if a transaction is opened, 0 otherwise var $transaction_opened; //! Last executed request var $lastquery; @@ -393,7 +393,7 @@ class DoliDBSqlite { if ($this->db) { - //dol_syslog(get_class($this)."::disconnect",LOG_DEBUG); + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR); $this->connected=0; $this->db=null; // Clean this->db return true; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b6dc024b0e3..4d9ff9b2f81 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Christophe Combelles @@ -229,9 +229,10 @@ function getEntity($element=false, $shared=false) function dol_shutdown() { global $conf,$user,$langs,$db; - $disconnectdone=false; - if (is_object($db) && ! empty($db->connected)) $disconnectdone=$db->close(); - dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced)':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG)); + $disconnectdone=false; $depth=0; + print 'xx'.$db->connected; + if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); } + dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG)); } From 9d2afc5feab7a8df0c2f807fc9032e20ee3560c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Feb 2012 17:09:13 +0100 Subject: [PATCH 3/3] New: Increase speed when switching to auguria module. Add error management. --- htdocs/admin/menus.php | 21 +++++++++------- htdocs/core/lib/admin.lib.php | 40 ++++++++++++++++--------------- htdocs/core/lib/functions.lib.php | 1 - 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 9b63b00f195..23c7ee04983 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -74,7 +74,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1; // Initialize menu handlers - $errmsgs=array(); + $error=0; $errmsgs=array(); foreach ($listofmenuhandler as $key => $val) { // Load sql init_menu_handler.sql file @@ -85,24 +85,29 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can if (file_exists($fullpath)) { $db->begin(); - $result=run_sql($fullpath,1,'',1,$key); + + $result=run_sql($fullpath,1,'',1,$key,'none'); if ($result > 0) { $db->commit(); } else { + $error++; $errmsgs[]='Failed to initialize menu '.$key.'.'; $db->rollback(); } } } - $db->close(); - - // We make a header redirect because we need to change menu NOW. - header("Location: ".$_SERVER["PHP_SELF"]); - exit; + if (! $error) + { + $db->close(); + + // We make a header redirect because we need to change menu NOW. + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } } @@ -251,7 +256,7 @@ else print ''; -dol_htmloutput_errors($errmsgs); +dol_htmloutput_errors('',$errmsgs); if (! isset($_GET["action"]) || $_GET["action"] != 'edit') diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 116e4835b20..d64192c28d0 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -108,13 +108,14 @@ function versiondolibarrarray() * @param int $entity Entity targeted for multicompany module * @param int $usesavepoint 1=Run a savepoint before each request and a rollback to savepoint if error (this allow to have some request with errors inside global transactions). * @param string $handler Handler targeted for menu + * @param string $okerror Family of errors we accept ('default', 'none') * @return int <=0 if KO, >0 if OK */ -function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='') +function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$okerror='default') { global $db, $conf, $langs, $user; - dol_syslog("Admin.lib::run_sql run sql file ".$sqlfile." silent=".$silent." entity=".$entity." usesavepoint=".$usesavepoint." handler=".$handler, LOG_DEBUG); + dol_syslog("Admin.lib::run_sql run sql file ".$sqlfile." silent=".$silent." entity=".$entity." usesavepoint=".$usesavepoint." handler=".$handler." okerror=".$okerror, LOG_DEBUG); $ok=0; $error=0; @@ -317,24 +318,25 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='') $errno=$db->errno(); if (! $silent) print ''."\n"; - $okerror=array( 'DB_ERROR_TABLE_ALREADY_EXISTS', - 'DB_ERROR_COLUMN_ALREADY_EXISTS', - 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', - 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS', // PgSql use same code for table and key already exist - 'DB_ERROR_RECORD_ALREADY_EXISTS', - 'DB_ERROR_NOSUCHTABLE', - 'DB_ERROR_NOSUCHFIELD', - 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP', - 'DB_ERROR_NO_INDEX_TO_DROP', - 'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante - 'DB_ERROR_CANT_DROP_PRIMARY_KEY', - 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' + // Define list of errors we accept (array $okerrors) + $okerrors=array( // By default + 'DB_ERROR_TABLE_ALREADY_EXISTS', + 'DB_ERROR_COLUMN_ALREADY_EXISTS', + 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', + 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS', // PgSql use same code for table and key already exist + 'DB_ERROR_RECORD_ALREADY_EXISTS', + 'DB_ERROR_NOSUCHTABLE', + 'DB_ERROR_NOSUCHFIELD', + 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP', + 'DB_ERROR_NO_INDEX_TO_DROP', + 'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante + 'DB_ERROR_CANT_DROP_PRIMARY_KEY', + 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ); - if (in_array($errno,$okerror)) - { - //if (! $silent) print $langs->trans("OK"); - } - else + if ($okerror == 'none') $okerrors=array(); + + // Is it an error we accept + if (! in_array($errno,$okerrors)) { if (! $silent) print ''; if (! $silent) print '
'.$langs->trans("Error")." ".$db->errno().": ".$newsql."
".$db->error()."
"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4d9ff9b2f81..3ba43241c47 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -230,7 +230,6 @@ function dol_shutdown() { global $conf,$user,$langs,$db; $disconnectdone=false; $depth=0; - print 'xx'.$db->connected; if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); } dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG)); }