diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 6225c0cc5011acab9c1804b3b82ee6a73a06bf3a..edee1e5cba320926b28e199b8da48029a66e3568 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -383,7 +383,8 @@ function dol_count_nb_of_line($file)
 		while (!feof($fp))
 		{
 			$line=fgets($fp);
-			$nb++;
+            // We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines.
+			if (! $line === false) $nb++;
 		}
 		fclose($fp);
 	}
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index f35c565d071ed9936489f10038cb68877022812c..d45f183faa256fb54c8e674547040167b4a7da16 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -452,17 +452,19 @@ class ImportCsv extends ModeleImports
 				}
 
 				// Loop on each hidden fields
-				foreach($objimport->array_import_fieldshidden[0] as $key => $val)
+				if (is_array($objimport->array_import_fieldshidden[0]))
 				{
-				    if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue;    // Not a field of current table
-				    if ($listfields) { $listfields.=', '; $listvalues.=', '; }
-				    if ($val == 'user->id')
-				    {
-				        $listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
-				        $listvalues.=$user->id;
-				    }
+    				foreach($objimport->array_import_fieldshidden[0] as $key => $val)
+    				{
+    				    if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue;    // Not a field of current table
+    				    if ($listfields) { $listfields.=', '; $listvalues.=', '; }
+    				    if ($val == 'user->id')
+    				    {
+    				        $listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
+    				        $listvalues.=$user->id;
+    				    }
+    				}
 				}
-
 				//print 'Show listfields='.$listfields.'<br>listvalues='.$listvalues.'<br>';
 
 				if (! $errorforthistable)
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 34af1fc11a7e29470b3a9ba5c546ba63081c464a..bf8eacb2c39b3be5171ae87bb0d4a094825789f0 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
  * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
  * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
@@ -21,10 +21,13 @@
 
 /**
  *	\defgroup   produit     Module products
- *	\brief      Module pour gerer le suivi de produits predefinis
+ *	\brief      Module to manage catalog of predefined products
+ */
+
+/**
  *	\file       htdocs/core/modules/modProduct.class.php
  *	\ingroup    produit
- *	\brief      Fichier de description et activation du module Produit
+ *	\brief      File to describe module to manage catalog of predefined products
  */
 
 include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
@@ -154,7 +157,7 @@ class modProduct extends DolibarrModules
 		$this->import_tables_creator_array[$r]=array('p'=>'fk_user_author');	// Fields to store import user id
 		$this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.duration'=>"Duration",'p.weight'=>"Weight",'p.volume'=>"Volume",'p.datec'=>'DateCreation*');
 		$this->import_entities_array[$r]=array();	// We define here only fields that use another picto
-		$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]','p.tobuy'=>'^[0|1]','p.fk_product_type'=>'^[0|1]','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
+		$this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
 		$this->import_examplevalues_array[$r]=array('p.ref'=>"PR123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31');
 	}