瀏覽代碼

Fix compatibility with PHP 8.1 and Psotgresql

Laurent Destailleur 2 年之前
父節點
當前提交
2b3f6cc173
共有 2 個文件被更改,包括 12 次插入2 次删除
  1. 2 2
      ChangeLog
  2. 10 0
      htdocs/core/lib/functions.lib.php

+ 2 - 2
ChangeLog

@@ -9,8 +9,8 @@ English Dolibarr ChangeLog
 For users:
 For users:
 ---------------
 ---------------
 
 
-NEW: PHP 8.0 compatibility (with mysql):
-     Warning!! Application works correctly with PHP 8.0 but you will experience a lot of PHP warnings into the PHP server
+NEW: PHP 8.0 and 8.1 compatibility (with mysql):
+     Warning!! Application works correctly with PHP 8.0 and 8.1 but you will experience a lot of PHP warnings into the PHP server
      log files (depending on your PHP setup). Removal of all PHP warnings on server side is planned for v17.
      log files (depending on your PHP setup). Removal of all PHP warnings on server side is planned for v17.
 NEW: Support for recurring purchase invoices.
 NEW: Support for recurring purchase invoices.
 NEW: #20292 Include German public holidays
 NEW: #20292 Include German public holidays

+ 10 - 0
htdocs/core/lib/functions.lib.php

@@ -1156,7 +1156,17 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
 function dol_clone($object, $native = 0)
 function dol_clone($object, $native = 0)
 {
 {
 	if (empty($native)) {
 	if (empty($native)) {
+		$tmpsavdb = null;
+		if (isset($object->db) && isset($object->db->db) && is_object($object->db->db) && get_class($object->db->db) == 'PgSql\Connection') {
+			$tmpsavdb = $object->db;
+			unset($object->db);		// Such property can not be serialized when PgSql/Connection
+		}
+
 		$myclone = unserialize(serialize($object));	// serialize then unserialize is hack to be sure to have a new object for all fields
 		$myclone = unserialize(serialize($object));	// serialize then unserialize is hack to be sure to have a new object for all fields
+
+		if ($tmpsavdb) {
+			$object->db = $tmpsavdb;
+		}
 	} else {
 	} else {
 		$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep the reference (refering to the same target/variable)
 		$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep the reference (refering to the same target/variable)
 	}
 	}