Browse Source

Fix: Pb of object with wrong type.

Laurent Destailleur 10 years ago
parent
commit
445f696d28

+ 36 - 1
.scrutinizer.yml

@@ -180,10 +180,45 @@ tools:
                 - 'htdocs/includes/*'
             paths: {  }
 
+	php_changetracking:
+        enabled: false
+        bug_patterns:
+            - '\bfix(?:es|ed)?\b'
+        feature_patterns:
+            - '\badd(?:s|ed)?\b'
+            - '\bimplement(?:s|ed)?\b'
+        filter:
+            excluded_paths:
+                - 'build/*'
+                - 'dev/*'
+                - 'doc/*'
+                - 'test/*'
+                - 'htdocs/includes/*'
+            paths: {  }
+            
     # Coding-Style / Bug Detection
-    js_hint: false
+	js_hint:
+		enabled: false
+	    use_native_config: true
+	    extensions:
+	        - js
+	    filter:
+	        excluded_paths:
+	            - 'build/*'
+	            - 'dev/*'
+	            - 'doc/*'
+	            - 'test/*'
+	            - 'htdocs/includes/*'
+	        paths: {  }
+	    config: {  }
+	    path_configs: {  }
 
 
+checks:
+    php:
+        code_rating: true
+        duplication: true
+        
 before_commands: {  }
 after_commands: {  }
 artifacts: {  }

+ 1 - 1
dev/skeletons/skeleton_class.class.php

@@ -182,7 +182,7 @@ class Skeleton_Class extends CommonObject
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return int     		   	 <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;

+ 8 - 10
htdocs/categories/class/categorie.class.php

@@ -107,7 +107,7 @@ class Categorie extends CommonObject
 				$this->type			= $res['type'];
 				$this->entity		= $res['entity'];
 
-				$this->fetch_optionals($this->id,$extralabels);
+				$this->fetch_optionals($this->id,null);
 
 				$this->db->free($resql);
 
@@ -202,7 +202,7 @@ class Categorie extends CommonObject
 				// FIXME le hook fait double emploi avec le trigger !!
 				$hookmanager->initHooks(array('HookModuleNamedao'));
 				$parameters=array('socid'=>$this->id);
-				$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
+				$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,'create');    // Note that $action and $object may have been modified by some hooks
 				if (empty($reshook))
 				{
 					if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
@@ -294,7 +294,7 @@ class Categorie extends CommonObject
 			// FIXME le hook fait double emploi avec le trigger !!
 			$hookmanager->initHooks(array('HookCategorydao'));
 			$parameters=array();
-			$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
+			$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,'update');    // Note that $action and $object may have been modified by some hooks
 			if (empty($reshook))
 			{
 				if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
@@ -419,7 +419,7 @@ class Categorie extends CommonObject
 				$error++;
 			}
 		}
-		
+
 		// Delete category
 		if (! $error)
 		{
@@ -441,7 +441,7 @@ class Categorie extends CommonObject
 						if ($result < 0)
 						{
 							$error++;
-							dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
+							dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR);
 						}
 					}
 				}
@@ -799,7 +799,7 @@ class Categorie extends CommonObject
 	 */
 	function get_full_arbo($type,$markafterid=0)
 	{
-	    global $langs;
+	    global $conf, $langs;
 
 		$this->cats = array();
 
@@ -809,11 +809,9 @@ class Categorie extends CommonObject
 
 		// Init $this->cats array
 		$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent";	// Distinct reduce pb with old tables with duplicates
-		if (! empty($conf->global->MAIN_MULTILANGS))
-		    $sql.= ", t.label as label_trans, t.description as description_trans";
+		if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans";
 		$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
-		if (! empty($conf->global->MAIN_MULTILANGS))
-		    $sql.= " LEFT  JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
+		if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT  JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
 		$sql.= " WHERE c.entity IN (".getEntity('category',1).")";
 		$sql.= " AND c.type = ".$type;
 

+ 1 - 1
htdocs/comm/propal/class/propal.class.php

@@ -2118,7 +2118,7 @@ class Propal extends CommonObject
 
                     if (! $error)
                     {
-                        dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG);
+                        dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG);
                         $this->db->commit();
                         return 1;
                     }

+ 2 - 2
htdocs/compta/bank/class/account.class.php

@@ -1145,7 +1145,7 @@ class AccountLine extends CommonObject
      *		@param	User	$user	User object that delete
      *      @return	int 			<0 if KO, >0 if OK
      */
-    function delete($user=0)
+    function delete($user=null)
     {
         $nbko=0;
 
@@ -1194,7 +1194,7 @@ class AccountLine extends CommonObject
      *		@param	User	$user	User object that delete
      *      @return	int 			<0 if KO, >0 if OK
      */
-    function delete_urls($user=0)
+    function delete_urls($user=null)
     {
         $nbko=0;
 

+ 1 - 1
htdocs/compta/bank/class/bankcateg.class.php

@@ -172,7 +172,7 @@ class BankCateg // extends CommonObject
      *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
      *  @return int         			<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
         global $conf, $langs;
         $error=0;

+ 1 - 1
htdocs/compta/facture/class/facture.class.php

@@ -1040,7 +1040,7 @@ class Facture extends CommonInvoice
 	 *      @param      int		$notrigger	    0=launch triggers after, 1=disable triggers
 	 *      @return     int      			   	<0 if KO, >0 if OK
 	 */
-	function update($user=0, $notrigger=0)
+	function update($user=null, $notrigger=0)
 	{
 		global $conf, $langs;
 		$error=0;

+ 1 - 1
htdocs/compta/facture/class/paymentterm.class.php

@@ -261,7 +261,7 @@ class PaymentTerm // extends CommonObject
      *      @param      int		$notrigger	    0=launch triggers after, 1=disable triggers
      *      @return     int       			  	<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;

+ 1 - 1
htdocs/compta/localtax/class/localtax.class.php

@@ -127,7 +127,7 @@ class Localtax extends CommonObject
      *	@param		int		$notrigger		0=no, 1=yes (no update trigger)
      *	@return		int						<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 

+ 2 - 2
htdocs/compta/salaries/class/paymentsalary.class.php

@@ -73,7 +73,7 @@ class PaymentSalary extends CommonObject
 	 * @param	int		$notrigger	    0=no, 1=yes (no update trigger)
 	 * @return  int         			<0 if KO, >0 if OK
 	 */
-	function update($user=0, $notrigger=0)
+	function update($user=null, $notrigger=0)
 	{
 		global $conf, $langs;
 
@@ -144,7 +144,7 @@ class PaymentSalary extends CommonObject
 	 *  @param  User	$user       User that load
 	 *  @return int         		<0 if KO, >0 if OK
 	 */
-	function fetch($id, $user=0)
+	function fetch($id, $user=null)
 	{
 		global $langs;
 		$sql = "SELECT";

+ 1 - 1
htdocs/compta/sociales/class/paymentsocialcontribution.class.php

@@ -220,7 +220,7 @@ class PaymentSocialContribution extends CommonObject
 	 *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
 	 *  @return int         			<0 if KO, >0 if OK
 	 */
-	function update($user=0, $notrigger=0)
+	function update($user=null, $notrigger=0)
 	{
 		global $conf, $langs;
 		$error=0;

+ 2 - 2
htdocs/compta/tva/class/tva.class.php

@@ -143,7 +143,7 @@ class Tva extends CommonObject
      * @param	int		$notrigger	    0=no, 1=yes (no update trigger)
      * @return  int         			<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 
@@ -205,7 +205,7 @@ class Tva extends CommonObject
      *  @param  User	$user       User that load
      *  @return int         		<0 if KO, >0 if OK
      */
-    function fetch($id, $user=0)
+    function fetch($id, $user=null)
     {
     	global $langs;
         $sql = "SELECT";

+ 3 - 3
htdocs/contact/class/contact.class.php

@@ -220,7 +220,7 @@ class Contact extends CommonObject
 	 *      @param		string	$action			Current action for hookmanager
 	 *      @return     int      			   	<0 if KO, >0 if OK
 	 */
-	function update($id, $user=0, $notrigger=0, $action='update')
+	function update($id, $user=null, $notrigger=0, $action='update')
 	{
 		global $conf, $langs, $hookmanager;
 
@@ -427,7 +427,7 @@ class Contact extends CommonObject
 	 *  @param      User		$user		User asking to change alert or birthday
      *  @return     int         			<0 if KO, >=0 if OK
 	 */
-	function update_perso($id, $user=0)
+	function update_perso($id, $user=null)
 	{
 	    $error=0;
 	    $result=false;
@@ -492,7 +492,7 @@ class Contact extends CommonObject
 	 *  @param      User	$user        Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact
 	 *  @return     int     		    -1 if KO, 0 if OK but not found, 1 if OK
 	 */
-	function fetch($id, $user=0)
+	function fetch($id, $user=null)
 	{
 		global $langs;
 

+ 1 - 1
htdocs/contrat/class/contrat.class.php

@@ -989,7 +989,7 @@ class Contrat extends CommonObject
 	 *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
 	 *  @return int     		   	 <0 if KO, >0 if OK
 	 */
-	function update($user=0, $notrigger=0)
+	function update($user=null, $notrigger=0)
 	{
 		global $conf, $langs;
 		$error=0;

+ 1 - 1
htdocs/core/class/ccountry.class.php

@@ -191,7 +191,7 @@ class Ccountry // extends CommonObject
      *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return     int     		   	 <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;

+ 1 - 1
htdocs/core/class/ctypent.class.php

@@ -198,7 +198,7 @@ class Ctypent // extends CommonObject
      *  @param      int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return     int     		   	 <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;

+ 2 - 2
htdocs/core/class/events.class.php

@@ -154,7 +154,7 @@ class Events // extends CommonObject
 	 * @param   int		$notrigger	    0=no, 1=yes (no update trigger)
 	 * @return  int         			<0 if KO, >0 if OK
 	 */
-	function update($user=0, $notrigger=0)
+	function update($user=null, $notrigger=0)
 	{
 		global $conf, $langs;
 
@@ -191,7 +191,7 @@ class Events // extends CommonObject
 	 *  @param  User	$user       User that load
 	 *  @return int         		<0 if KO, >0 if OK
 	 */
-	function fetch($id, $user=0)
+	function fetch($id, $user=null)
 	{
 		global $langs;
 

+ 3 - 3
htdocs/core/class/menubase.class.php

@@ -74,7 +74,7 @@ class Menubase
      *      @param      User	$user       User that create
      *      @return     int      			<0 if KO, Id of record if OK
      */
-    function create($user=0)
+    function create($user=null)
     {
         global $conf, $langs;
 
@@ -185,7 +185,7 @@ class Menubase
      *  @param  int		$notrigger	    0=no, 1=yes (no update trigger)
      *  @return int 		        	<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
         global $conf, $langs;
 
@@ -250,7 +250,7 @@ class Menubase
      *   @param		User    $user       User that load
      *   @return	int         		<0 if KO, >0 if OK
      */
-    function fetch($id, $user=0)
+    function fetch($id, $user=null)
     {
         global $langs;
 

+ 2 - 2
htdocs/cron/class/cronjob.class.php

@@ -96,7 +96,7 @@ class Cronjob extends CommonObject
 		$error=0;
 
 		$now=dol_now();
-		
+
 		// Clean parameters
 
 		if (isset($this->label)) $this->label=trim($this->label);
@@ -501,7 +501,7 @@ class Cronjob extends CommonObject
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return int     		   	 <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 

+ 1 - 1
htdocs/ecm/class/ecmdirectory.class.php

@@ -184,7 +184,7 @@ class EcmDirectory // extends CommonObject
 	 *  @param 	int		$notrigger	    0=no, 1=yes (no update trigger)
 	 *  @return int 			       	<0 if KO, >0 if OK
 	 */
-	function update($user=0, $notrigger=0)
+	function update($user=null, $notrigger=0)
 	{
 		global $conf, $langs;
 

+ 1 - 1
htdocs/expedition/class/expedition.class.php

@@ -800,7 +800,7 @@ class Expedition extends CommonObject
      *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
      *  @return int 			       	<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;

+ 1 - 1
htdocs/fourn/class/fournisseur.facture.class.php

@@ -539,7 +539,7 @@ class FactureFournisseur extends CommonInvoice
      *  @param  int		$notrigger       0=launch triggers after, 1=disable triggers
      *  @return int 			         <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
         global $conf, $langs;
         $error=0;

+ 1 - 1
htdocs/holiday/class/holiday.class.php

@@ -470,7 +470,7 @@ class Holiday extends CommonObject
      *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
      *  @return int         			<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
         global $conf, $langs;
         $error=0;

+ 1 - 1
htdocs/opensurvey/class/opensurveysondage.class.php

@@ -254,7 +254,7 @@ class Opensurveysondage extends CommonObject
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return int     		   	 <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;

+ 13 - 13
htdocs/product/class/productbatch.class.php

@@ -34,7 +34,7 @@ class Productbatch extends CommonObject
 	private static $_table_element='product_batch';		//!< Name of table without prefix where object is stored
 
     var $id;
-    
+
 	var $tms='';
 	var $fk_product_stock;
 	var $sellby='';
@@ -43,7 +43,7 @@ class Productbatch extends CommonObject
 	var $qty;
 	var $import_key;
 
-    
+
 
 
     /**
@@ -92,7 +92,7 @@ class Productbatch extends CommonObject
 		$sql.= " ".(! isset($this->qty)?'NULL':$this->qty).",";
 		$sql.= " ".(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'")."";
 
-        
+
 		$sql.= ")";
 
 		$this->db->begin();
@@ -148,7 +148,7 @@ class Productbatch extends CommonObject
 		global $langs;
 		$sql = "SELECT";
 		$sql.= " t.rowid,";
-		
+
 		$sql.= " t.tms,";
 		$sql.= " t.fk_product_stock,";
 		$sql.= " t.sellby,";
@@ -157,7 +157,7 @@ class Productbatch extends CommonObject
 		$sql.= " t.qty,";
 		$sql.= " t.import_key";
 
-		
+
         $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t";
         $sql.= " WHERE t.rowid = ".$id;
 
@@ -196,7 +196,7 @@ class Productbatch extends CommonObject
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return int     		   	 <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;
@@ -376,7 +376,7 @@ class Productbatch extends CommonObject
 	function initAsSpecimen()
 	{
 		$this->id=0;
-		
+
 		$this->tms='';
 		$this->fk_product_stock='';
 		$this->sellby='';
@@ -384,14 +384,14 @@ class Productbatch extends CommonObject
 		$this->batch='';
 		$this->import_key='';
 
-		
+
 	}
 
 	/**
 	 * Clean fields (triming)
 	 *
 	 *	@return	void
-	 */ 
+	 */
 	private function clean_param() {
 		if (isset($this->fk_product_stock)) $this->fk_product_stock=(int) trim($this->fk_product_stock);
 		if (isset($this->batch)) $this->batch=trim($this->batch);
@@ -429,7 +429,7 @@ class Productbatch extends CommonObject
 		if (! empty($batch_number)) $sql.= " AND batch = '".$this->db->escape($batch_number)."'";
 
 		if (! empty($where)) $sql.= " AND (".implode(" OR ",$where).")";
-		
+
     	dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
         $resql=$this->db->query($sql);
         if ($resql)
@@ -439,7 +439,7 @@ class Productbatch extends CommonObject
                 $obj = $this->db->fetch_object($resql);
 
                 $this->id    = $obj->rowid;
-                
+
 				$this->tms = $this->db->jdate($obj->tms);
 				$this->fk_product_stock = $obj->fk_product_stock;
 				$this->sellby = $this->db->jdate($obj->sellby);
@@ -480,10 +480,10 @@ class Productbatch extends CommonObject
 		$sql.= " t.qty,";
 		$sql.= " t.import_key";
 
-		
+
         $sql.= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as t";
 		$sql.= " WHERE fk_product_stock=".$fk_product_stock;
-		
+
 		if ($with_qty) $sql.= " AND qty<>0";
 		dol_syslog("productbatch::findAll", LOG_DEBUG);
 		$resql=$db->query($sql);

+ 2 - 2
htdocs/projet/class/task.class.php

@@ -261,7 +261,7 @@ class Task extends CommonObject
      *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
      *  @return int			         	<0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
         global $conf, $langs;
         $error=0;
@@ -801,7 +801,7 @@ class Task extends CommonObject
                 $this->db->rollback();
                 $ret = -2;
             }
-        
+
             $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time";
             $sql.= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")";
             $sql.= " WHERE rowid = ".$tasktime_id;

+ 2 - 2
htdocs/resource/class/resource.class.php

@@ -205,7 +205,7 @@ class Resource extends CommonObject
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return int     		   	 <0 if KO, >0 if OK
      */
-    function update($user=0, $notrigger=0)
+    function update($user=null, $notrigger=0)
     {
     	global $conf, $langs;
     	$error=0;
@@ -695,7 +695,7 @@ class Resource extends CommonObject
      *  @param  int		$notrigger	 0=launch triggers after, 1=disable triggers
      *  @return int     		   	 <0 if KO, >0 if OK
      */
-    function update_element_resource($user=0, $notrigger=0)
+    function update_element_resource($user=null, $notrigger=0)
     {
     	global $conf, $langs;
 		$error=0;

+ 2 - 2
htdocs/societe/class/address.class.php

@@ -232,7 +232,7 @@ class Address
 	 *  @param  User	$user        Objet de l'utilisateur
 	 *  @return int 			     >0 si ok, <0 si ko
 	 */
-	function fetch_lines($socid, $user=0)
+	function fetch_lines($socid, $user=null)
 	{
 		global $langs, $conf;
 
@@ -325,7 +325,7 @@ class Address
 	 *  @param  User	$user       Objet de l'utilisateur
 	 *  @return int 				>0 si ok, <0 si ko
 	 */
-	function fetch_address($id, $user=0)
+	function fetch_address($id, $user=null)
 	{
 		global $langs;
 		global $conf;