From abd8aea06b97f8eb3839c00fb5370da5b41a032d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:56:45 +0100 Subject: [PATCH] Fix: Log not reported Fix: charset not correctly forced Conflicts: htdocs/install/inc.php --- htdocs/install/etape1.php | 11 +++++++---- htdocs/install/inc.php | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 32717e18b80..009d953e73d 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -255,8 +255,10 @@ if (! $error && $db->connected) { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); - $defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + //$defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); + //$defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + $defaultCharacterSet=$db->forcecharset; + $defaultDBSortingCollation=$db->forcecollate; } else // If already created, we take current value { @@ -268,6 +270,7 @@ if (! $error && $db->connected) print ''; $db_character_set=$defaultCharacterSet; $db_collation=$defaultDBSortingCollation; + dolibarr_install_syslog("db_character_set=".$db_character_set." db_collation=".$db_collation); } @@ -559,8 +562,8 @@ if (! $error && $db->connected && $action == "set") // If database creation is asked, we create it if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on")) { - dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG); - $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); + dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user, LOG_DEBUG); + $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit; if ($newdb->connected) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 354ad1e8cbe..f078f7a1802 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -200,6 +200,7 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile)) // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); +if (! defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS','["mod_syslog_file"]'); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -230,7 +231,6 @@ foreach ($handlers as $handler) $conf->loghandlers[]=$loghandlerinstance; } - // Removed magic_quotes if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP 5.4 { @@ -314,7 +314,26 @@ function conf($dolibarr_main_document_root) //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); - + // We init log handler for install + $handlers = array('mod_syslog_file'); + foreach ($handlers as $handler) + { + $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; + if (!file_exists($file)) + { + throw new Exception('Missing log handler file '.$handler.'.php'); + } + + require_once $file; + $loghandlerinstance = new $handler(); + if (!$loghandlerinstance instanceof LogHandlerInterface) + { + throw new Exception('Log handler does not extend LogHandlerInterface'); + } + + $conf->loghandlers[]=$loghandlerinstance; + } + return 1; }