Laurent Destailleur 4 years ago
parent
commit
bcffbe3d67
3 changed files with 18 additions and 13 deletions
  1. 8 5
      .travis.yml
  2. 9 8
      htdocs/core/class/commonobject.class.php
  3. 1 0
      htdocs/core/db/pgsql.class.php

+ 8 - 5
.travis.yml

@@ -44,16 +44,20 @@ jobs:
   #allow_failures:
   #- php: nightly
   include:
-    - if: type = push
+    - stage: PHP 5.6
+      if: type = push
       php: '5.6'
       env: DB=postgresql
-    - if: type = pull_request OR type = push
+    - stage: PHP 7.4
+      if: type = pull_request OR type = push
       php: '7.4'
       env: DB=mysql
-    - if: type = push AND branch = develop
+    - stage: PHP Dev
+      if: type = push AND branch = develop
       php: nightly 
       env: DB=mysql
-    - if: type = push AND branch = 14.0
+    - stage: PHP Dev
+      if: type = push AND branch = 14.0
       php: nightly 
       env: DB=mysql
 
@@ -412,7 +416,6 @@ script:
 - |
   echo "Enabling new modules"
   # Enable modules not enabled into original dump
-  cd htdocs/install
   php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE > $TRAVIS_BUILD_DIR/enablemodule.log
   php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $TRAVIS_BUILD_DIR/enablemodule.log
   php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log

+ 9 - 8
htdocs/core/class/commonobject.class.php

@@ -1095,7 +1095,7 @@ abstract class CommonObject
 					$this->db->rollback();
 					return -2;
 				} else {
-					$this->error = $this->db->error();
+					$this->error = $this->db->lasterror();
 					$this->db->rollback();
 					return -1;
 				}
@@ -1119,7 +1119,6 @@ abstract class CommonObject
 		$contacts = $objFrom->liste_contact(-1, $source);
 		foreach ($contacts as $contact) {
 			if ($this->add_contact($contact['id'], $contact['fk_c_type_contact'], $contact['source']) < 0) {
-				$this->error = $this->db->lasterror();
 				return -1;
 			}
 		}
@@ -5760,8 +5759,10 @@ abstract class CommonObject
 			$table_element = 'categories'; // For compatibility
 		}
 
-		$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id;
 		dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG);
+
+		$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id;
+
 		$resql = $this->db->query($sql_del);
 		if (!$resql) {
 			$this->error = $this->db->lasterror();
@@ -8467,7 +8468,7 @@ abstract class CommonObject
 
 				$result = $line->create($user, 1);
 				if ($result < 0) {
-					$this->error = $this->db->lasterror();
+					$this->error = $line->error;
 					$this->db->rollback();
 					return -1;
 				}
@@ -8498,8 +8499,8 @@ abstract class CommonObject
 	/**
 	 * Load object in memory from the database
 	 *
-	 * @param	int    $id				Id object
-	 * @param	string $ref				Ref
+	 * @param	int    	$id				Id object
+	 * @param	string 	$ref			Ref
 	 * @param	string	$morewhere		More SQL filters (' AND ...')
 	 * @return 	int         			<0 if KO, 0 if not found, >0 if OK
 	 */
@@ -8808,8 +8809,8 @@ abstract class CommonObject
 		if (!$error) {
 			$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.((int) $this->id);
 
-			$res = $this->db->query($sql);
-			if ($res === false) {
+			$resql = $this->db->query($sql);
+			if (!$resql) {
 				$error++;
 				$this->errors[] = $this->db->lasterror();
 			}

+ 1 - 0
htdocs/core/db/pgsql.class.php

@@ -757,6 +757,7 @@ class DoliDBPgsql extends DoliDB
 
 			$errorlabel = pg_last_error($this->db);
 			$errorcode = '';
+			$reg = array();
 			if (preg_match('/: *([0-9P]+):/', $errorlabel, $reg)) {
 				$errorcode = $reg[1];
 				if (isset($errorcode_map[$errorcode])) {